Page 1 of 1
Turning Catagories Into A drop down menu
Posted: Thu Jun 10, 2010 4:21 am
by anannsul
To clarify I do not want to include catagories plug into a drop down menu. i want it to BE the drop down menu.
Catagory
--sub catagory
--sub catagory
catagory
with the sub catagories being only visible when the catagory is hovered over.
Is this possible?
Re: Turning Catagories Into A drop down menu
Posted: Thu Jun 10, 2010 3:08 pm
by garvinhicking
Hi!
You can enable the smarty templating options of the category plugin and then edit your template's plugin_category.tpl template file. In there, instead of li/checkbox elements you could turn them into options...
Regards,
Garvin
Re: Turning Catagories Into A drop down menu
Posted: Thu Jun 10, 2010 3:16 pm
by yellowled
garvinhicking wrote:In there, instead of li/checkbox elements you could turn them into options...
... or a neat CSS/JS-based dropdown menu like Son of Suckerfish.
YL
Re: Turning Catagories Into A drop down menu
Posted: Thu Jun 10, 2010 11:46 pm
by anannsul
Where do I get this son of suckerfish? Just google it?
and also, I do not understand how to edit the category.tpl
Re: Turning Catagories Into A drop down menu
Posted: Thu Jun 10, 2010 11:49 pm
by Don Chambers
anannsul wrote:Where do I get this son of suckerfish? Just google it?
and also, I do not understand how to edit the category.tpl
Yes, there are many different "suckerfish" navigation bar/drop down examples out there.... but I get the feeling you are looking for an option list, not a navigation list.
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 12:17 am
by anannsul
No, want the navigation....
Like here
http://www.htmldog.com/articles/suckerfish/dropdowns/
Only instead of going across the top it goes down in the sidebar.
The problem is I have no clue how to implement this into the category.tpl.
I only see one ul tag and one li and apparently it controls all of lists no matter how many levels there are.
=\
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 1:15 am
by Don Chambers
It is not going to be easy, but it can probably be done...
The smarty template contains a variable called {$plugin_category.catdepth}. For a top level category, that value will be 0. First level child will be 1, second will be 2, and so on. So, for each iteration of the foreach loop, you will need some way of comparing that catdepth to the last one. If they are not the same, then you will need to open a new ul for the nested subcategory. I think you will also need some way to know that you have opened a new ul too. Then when it changes again, you need to know if it is due to returning to the parent level, or opening a grandchild category (3rd level) and act accordingly.
At least, that's my first thought.... and my first thoughts are not often my best.
Sounds like more of a PITA than it is worth.

Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 1:28 am
by anannsul
I got the variable...
I'm messing around with if statements but it's just not working out. lol. However, I haven't reached that point of giving up yet... so as of right now i'm open to any ideas on how to get this working.
I don't know what code would get it to compare or know that it's opened a new ul tag
Right now i have
ul
foreach
If cat depth== 0
li
else
ul
li
/li
/ul
/if
/li
/foreach
/ul
But that isn't what I want either.. because as you can tell.. if it isn't 0 then it gets it's own ul and li tags. lol. and for some reason the cat depth 0 is ending it's li before the else statement. =\
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 1:34 am
by Don Chambers
I think you will get it figured out as it sounds like you are already on your way. Feel free to post actual code, and enclose it in code brackets.
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 3:11 am
by anannsul
Is there a variable to use in category.tpl that could check if the category is a parent or not?
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 6:05 am
by Don Chambers
anannsul wrote:Is there a variable to use in category.tpl that could check if the category is a parent or not?
Not that I know of. Perhaps someone knows better than I. I think cat depth is your best bet.
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 6:51 am
by anannsul
I think I'm going to throw in the white flag. lol
taking out the check boxes and rss thing.. I get this as a base
Code: Select all
<ul id="serendipity_categories_list" style="list-style: none; margin: 0px; padding: 0px">
{foreach from=$categories item="plugin_category"}
<li class="category_depth{$plugin_category.catdepth} category_{$plugin_category.categoryid}" style="display: block;">
<a href="{$plugin_category.categoryURL}" title="{$plugin_category.category_description|escape}" style="padding-left: {$plugin_category.paddingPx}px">{$plugin_category.category_name|escape}</a>
</li>
{/foreach}
</ul>
I have tried including an if statement just before the </li> tag
Code: Select all
<ul id="serendipity_categories_list" style="list-style: none; margin: 0px; padding: 0px">
{foreach from=$categories item="plugin_category"}
<li class="category_depth{$plugin_category.catdepth} category_{$plugin_category.categoryid}" style="display: block;">
<a href="{$plugin_category.categoryURL}" title="{$plugin_category.category_description|escape}" style="padding-left: {$plugin_category.paddingPx}px">{$plugin_category.category_name|escape}</a>
{if $plugin_category.catdepth > 0}
<ul>
<li><a href="{$plugin_category.categoryURL}" title="{$plugin_category.category_description|escape}" style="padding-left: {$plugin_category.paddingPx}px">{$plugin_category.category_name|escape}</a>
</li>
</ul>
{/if}
</li>
{/foreach}
</ul>
But that gives every thing listed below that it's own ul tag for EVERY item in the parent category. So, I really don't know what to do anymore. lol.. and i'm not THAT great at php either. x.x
I saw this
Code: Select all
{if ($smarty.foreach.myloop.iteration) % 4== 0}</tr><tr>{/if}
but what that does is after the foreach loops 4 times it ends a cell and starts a new one... but I don't know if it's even possible to assign something like that to the {$plugin_category.catdepth}.
Like
Code: Select all
{if $plugin_category.catdepth > 0} <ul>
{foreach}
<li><a href="{$plugin_category.categoryURL}" title="{$plugin_category.category_description|escape}" style="padding-left: {$plugin_category.paddingPx}px">{$plugin_category.category_name|escape}</a>
</li>
{/foreach}
</ul>
{/if}
but that doesn't work because when you look at the webpage and view the code
the parent somehow has the </li> after it anyway. >.<
._. I think this is way more advanced then what I know.

Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 7:06 am
by Don Chambers
Re: Turning Catagories Into A drop down menu
Posted: Fri Jun 11, 2010 7:09 am
by anannsul

You party animal, you! lol
It's alright, thank you for all your help.
