Turning Catagories Into A drop down menu
Turning Catagories Into A drop down menu
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?
Catagory
--sub catagory
--sub catagory
catagory
with the sub catagories being only visible when the catagory is hovered over.
Is this possible?
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Turning Catagories Into A drop down menu
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
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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Turning Catagories Into A drop down menu
... or a neat CSS/JS-based dropdown menu like Son of Suckerfish.garvinhicking wrote:In there, instead of li/checkbox elements you could turn them into options...
YL
Re: Turning Catagories Into A drop down menu
Where do I get this son of suckerfish? Just google it?
and also, I do not understand how to edit the category.tpl
and also, I do not understand how to edit the category.tpl
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Turning Catagories Into A drop down menu
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.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
=Don=
Re: Turning Catagories Into A drop down menu
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.
=\
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.
=\
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Turning Catagories Into A drop down menu
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.
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.
=Don=
Re: Turning Catagories Into A drop down menu
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. =\
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. =\
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Turning Catagories Into A drop down menu
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.
=Don=
Re: Turning Catagories Into A drop down menu
Is there a variable to use in category.tpl that could check if the category is a parent or not?
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Turning Catagories Into A drop down menu
Not that I know of. Perhaps someone knows better than I. I think cat depth is your best bet.anannsul wrote:Is there a variable to use in category.tpl that could check if the category is a parent or not?
=Don=
Re: Turning Catagories Into A drop down menu
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
I have tried including an if statement just before the </li> tag
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
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
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.
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>
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>
I saw this
Code: Select all
{if ($smarty.foreach.myloop.iteration) % 4== 0}</tr><tr>{/if}
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}
the parent somehow has the </li> after it anyway. >.<
._. I think this is way more advanced then what I know.
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Turning Catagories Into A drop down menu
I will look at this tomorrow, but perhaps someone else will respond prior to that. I am in Chicago, IL, USA and the Chicago Blackhawks won the Stanley Cup last night, and it has been a constant party since then, and I am - quite frankly - a little ....um... buzzed. Also watching the NBA finals here, so I am fairly worthless at the moment!!!
=Don=
Re: Turning Catagories Into A drop down menu
You party animal, you! lol
It's alright, thank you for all your help.
It's alright, thank you for all your help.