Log in

View Full Version : Counting number of elements in $navbits


chewbacca
06-16-2006, 08:29 PM
I'm new to the plug-in modification thing, so I'm not sure where to put any code. Is this even the right place to post a question?

Anyway, I'm trying to create a "list closer" for my breadcrumbs.

Using count($navbits) doesn't seem to work under the navbits, global_start, and global_complete hooks. Is there some variable or array somewhere that contains the number of pieces in the $navbits array?

Thank you.

Adrian Schneider
06-16-2006, 09:13 PM
The $navbits array is defined (usually) near the end of each script, then right after it is converted to HTML using the construct_navbits() function.

There is a "navbits" hook you can use, where $lastelement should contain the number of elements you are looking for.

chewbacca
06-16-2006, 09:38 PM
Thanks, I must've jumped over that sizeof()...

But now I've got another problem: I can't use the variable I defined in any template other than navbar_link. After reading up a little on plug-ins, I'm not even sure if I can use one to do what I want. Thanks again for your help.

Adrian Schneider
06-16-2006, 09:56 PM
Thanks, I must've jumped over that sizeof()...

But now I've got another problem: I can't use the variable I defined in any template other than navbar_link. After reading up a little on plug-ins, I'm not even sure if I can use one to do what I want. Thanks again for your help.
You could do something like this: global $yourVariable;
$yourVariable = $lastelement;$yourVariable should now work in most places.

chewbacca
06-16-2006, 10:41 PM
Hmm... I also tried doing global once before. All it did was turn my pages blank.

Edit: I global'd the variable on my live server rather than local, and it appears my local machine has some problem. I don't know what it is yet, but it works on the live server. Thank you for putting up with a newbie. :)

Edit: Upgraded to latest PHP5 on localhost and it works now.