Recent Topics

1 Aug 20, 2006 21:40    

How do I change the order of categories listed in the posts (i.e. NOT in the sidebar)? They list main first, then by ID, right? I would like to make it that sub-categories of the main category are listed before other sub-categories. In other words, I want: parent, child, stepchild, stepchild.

I've been working in the _functions_cats.php file and thought I could first list categories where the cat_parent_ID matches the main_cat_ID (in "function the_categories"), but absolutely nothing I've done has had any effect.

Any suggestions?

2 Aug 20, 2006 22:23

Try using [url=http://doc.b2evolution.net/v-0-9/evocore/Item.html#methodcategories]categories()[/url] instead and feed it the appropriate parameters from inside your _main.php file. Crack open your b2evocore/item_class.php file and search for "function categories" to see how to feed it the correct parameters, and especially note how you can use 'hide' as a parameter to hide some bits.

You'll end up calling the function twice. The first time you'll hide the main cat, and the second you'll end up hiding the subcats.

3 Aug 21, 2006 23:43

Pardon my ignorance, but I can't figure out how this helps me get the sub-category/-ies under the main category to come before sub-categories under other categories. IOW, what I get now is:
Main, subOther, subOther, subMain
because I added the subMain later, and so it has a higher ID.
What I want is:
Main, subMain, subOther, subOther

I don't see how these parameters can help me do this. ???

4 Aug 22, 2006 00:50

MoonChild,

I don't think that $Item->categories, by itself, will get you what you want - b2evo sees only "children" and not "children" -vs- "step children" (they're all lumped together under "other").

One potential solution would be to build some PHP logic: If the main cat == "blah", then store the "other" cats in an array. For every item in the array, see if they match the (known) children. If they do, spit them out. If not, store them into another array. Then, after you've matched all the children, spit out the step-children that are left over.

It'd be a tad messy (involve some spitting) and would need modification each time you added another sub-category, but it could probably be made to work. :D (Recommended only if your blog categories are stable and seldom change).

It's never a matter of CAN you do something, it's a matter of how much it'll cost you to achieve it (price, time, pain). ;)

Don't see an easier way, off-hand ... but just you wait, maybe some low-flying Brit will come along and prove me wrong. ;)

Hope this helps.

5 Aug 22, 2006 01:05

I misunderstood. My bad!

6 Aug 25, 2006 09:05

OMG, I pulled it off!
Since the categories are all from the same blog, I changed one line in the class_item.php categories function, where it checks whether the other categories are from the same blog. I changed it from:
elseif( $cat['cat_blog_ID'] == $this->blog_ID )
to:
elseif( $cat['cat_parent_ID'] == $this->main_cat_ID )
Then, in the _main.php file, I called it twice, first hiding the "external" categories (which are now the step-children), then hiding the "main" and "other" (child) categories.

Thanks for helping me get there!
If you want to see why I had to do this, and how great it works, look here: http://moonchild.ch/blog/index.php?blog=5

7 Aug 25, 2006 14:49

Oh.. me feeling jealous now ;)
I have the same kind of blog (recepies and ingredients...

I also want this kind of info... ;)

I'll have to spit out your blog very well...
Ar you willing to put in the code that youused exactly in your _main.php ?

(btw, there are a lot of visual errors in ie on xp)

8 Aug 25, 2006 16:31

Glad you got it sorted and it looks like it REALLY makes a your page "work properly"!

Three Cheers :D

(Agree with Topanga, the skin is breaking in IE ... maybe the .bPosts DIV needs to be a tad narrower?)

9 Aug 26, 2006 00:08

Topanga wrote:

Ar you willing to put in the code that youused exactly in your _main.php ?

I replaced $Item->categories(); with:

$Item->categories( '#','', '','', '','hide', 'hide',', ','htmlbody' ); echo ', ';
$Item->categories( '#','hide','hide','hide','hide','<em>', '</em>',', ','htmlbody' )

(btw, there are a lot of visual errors in ie on xp)

What a mess! I don't have any M*cr*s*ft products on my machine, so I went on my husband's laptop to have a look. HORRIBLE! What am I going to do now?

10 Aug 26, 2006 00:16

Fix it. ;)

It's a horizontal width problem between the container (total width) and the sidebar/content DIVS (+padding/margins/border-widths). IE is very fussy about block-level elements all "fitting" into the space they're allocated.

I suggest you start by reducing the width of the .bPosts DIV and see if that makes a difference (see how it overlaps the sidebar in IE?)

If you need help sorting it, just PM or email me. B)

11 Aug 26, 2006 00:57

Yes, that's pretty straightforward, but that's not how it looks in my IE. It's got LOTS of problems, primarily the font size being about three times bigger, and the inability of the categories to collapse. Does it look totally different in every version, or what? How am I supposed to deal with that? I am feeling extremely discouraged!
At least now I understand why everyone else's blogs have such tiny text. Everyone uses IE, and it doesn't look that tiny to them.

12 Aug 26, 2006 01:49

Don't despair. :( I sent you an email that includes an image of what I'm seeing in IE and it's not nearly as bad as you describe.

Maybe your hubby's laptop IE settings are kinda weird? (JavaScript is off maybe? dunno.) The collapsible cats worked for me. :D

Run the page through the [url=http://validator.w3.org/check?uri=http%3A%2F%2Fmoonchild.ch%2Fblog%2Findex.php%3Fblog%3D5]W3C Validation Service[/url]. You'll see 12 errors, most of which are related to the use of CAPITALS for some of your tag attribute names (instead of the xhtml-valid lowercase), mostly.

"language" isn't used with <script> anymore, in favor of type="text/javascript".

I'd fix those few errors and check again. Also check the font size setting in IE too.

Regardless, the image should keep you from the edge of dispair! ;) :D

Hope this helps!

Cheers,

13 Apr 26, 2007 01:48

I'm working on a blog with six main categories and 78 expandable subcategories. I want to check two main categories for each post, so that they show up on the postcounts. But on the posts, I only want to list the subcategories, with the MAIN main category's subcategory listed first. In other words: subMain and subOther. So I changed part of the categories function in the inc/MODEL/items/_item.class.php file

			if( $cat_ID == $this->main_cat_ID )
			{ // We are displaying the main cat!
				if( $before_main == 'hide' )
				{ // ignore main cat !!!
					continue;
				}
				$cat_name = $before_main.$cat_name.$after_main;
			}
			elseif( $cat['cat_parent_ID'] == $this->main_cat_ID )
			{ // We are displaying another cat in the main cat
				if( $before_other == 'hide' )
				{ // ignore main cat !!!
					continue;
				}
				$cat_name = $before_other.$cat_name.$after_other;
			}
			elseif( $cat['cat_parent_ID'] == NULL )
			{ 
					continue;
			}
			else
			{ // We are displaying an external cat (in another cat)
				if( $before_external == 'hide' )
				{ // ignore main cat !!!
					continue;
				}
				$cat_name = $before_external.$cat_name.$after_external;
			}


And put this in the _main.php file

			echo '<br /> ', T_('Categories'), ': ';
			$Item->categories('','hide','','','','hide', '',', ','htmlbody' );
			echo ' and ';
			$Item->categories('','hide','','hide','','', '',', ','htmlbody' );


Just thought I'd make a record of it, in case anyone else out there is as obsessive-compulsive about their categories as I am.


Form is loading...