Ok, I give up. I’ve been struggling to figure this out and just can’t so I’m hoping someone can help.
I’ve created a horizontal menu and coded it in, but I want the appropriate menu item to be highlighted when it is the active thing. I don’t know how to describe what I want to do so I’ll show you.
This is how my menu looks now:
This is how I want it to look:
This is the code I am using, but it isn’t working quite right:
I “think” you’re going to have to get to the actual dispatch= syntax for the current_url. Since this is all dynamic, it needs to fall down to the lowest denominator which would be the dispatch syntax of dispatch=categories.view&category_id=7 or some such.
What is the value of $current_url in the context you are in (insert a {debug} into your template)?
I was asking what the value of $current_url is within the template that you are trying to set the ‘active page’ for. The best way to derive this is to add [debug} to the bottom of the template and then post the value of ‘current_url’ here. I was mostly curious as to whether it was of the dispatch variety or whether it was set to the seo name of the page.
Without knowing what $current_url is, it’s hard to develop an ‘if’ statement related to it.
Then in your template simply match $my_cat_name against whatever you’e using to display your category names. When they match, apply your special styling (suggest it be a separate CSS class rather than an embedded style).
Well, I ended up using Adodric’s first suggestion and it works. It would be nice if there was an easier way of doing this though.
I tried both Tbirnseth’s and Sno’s ways, but neither worked. I’m not sure why Tbirneth’s didn’t, but I think Sno’s has something to do with the SEO addon, but I’m not sure.
Because I only have a few categories, this works. One thing I would really like to improve is to make it so the products under the categories do the same thing as the category. As you can see, I’ve done that above. It would just be nice if it could be more dynamic or something.
The biggest thing about how I’ve done this is that this will only work as long as I only have a limited number of products and categories. If I start adding a lot more products I’ll have to figure out a different design.
Based upon my code above do you guys have any ideas on how I can clean this up and make it more dynamic or something?
You may be able to code some elements into the manage category page to do this for you… I coded a Nested Blocks Addon which uses a similar method of using elements like checkboxes to display blocks within another block, the checkboxes enable me to position blocks anywhere on the product pages like central left, central middle, central right, central width ect…You can also use pull-down menus but I liked the checkboxes better. I’m thinking you can probably do the same thing to enable which tpl or css file to use if activated and you would be able to integrate the bulk edit feature to change the parameters more quickly.
What do you mean “so the products under the categories do the same thing as the category” can you provide a screenshot? Thanks - Sno
I tried Adodric’s idea, but it didn’t work. I haven’t really researched what stripos does so maybe there is a way.
I did the “Or” statements, but when I did it for one category it gave the same results for all the categories. If I only had on or statement it works, but when I do all five it doesn’t. Kind of weird.
I’d be curious to see what you already have Sno. Do you think you could send me the file(s)?
Also, as for the category question, you hit the nail on the head with your code you gave above, I just couldn’t figure out how to word it, sorry.
Anyways, I sure appreciate the time you guys have spent on this. Thanks.
The menu showed up fine, but the category that was chosen wasn’t orange. If you look at the first image in this post you will see that I have an orange background image for my menu. I just want the active category to be orange.
That makes my menu work great. I’m assuming that by using stristr it will make it so that anything that comes under a certain category will make the if statement true?
Basically any subcategory or product under lingcod-jigs for example will make my if statement true?
I sure wish I could explain myself better, but hopefully you get what I mean.
Anyways, thanks for your help I really appreciate it. I’m just glad to have this figured out. Now I can move on.
Basically any subcategory or product under lingcod-jigs for example will make my if statement true?
[/QUOTE]
Yes, exactly.
As long as you keep the SEO url the way it is by listing the parent category urls in it. If you did change your url formatting, as long as their is a common string in all of the related categories then you can always use it. You could just use “ling”, “rock”, or “tuna” also, which might slightly speed it up since it is less to check for.