X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Highlight current page in speedbar (https://forum.x-cart.com/showthread.php?t=53581)

FTI 05-03-2010 01:18 PM

Highlight current page in speedbar
 
1 Attachment(s)
Hi there, currently I'm trying to highlight the speedbar link for the current page on which the user is. See the attached image to get my idea. So basicly when a user clicks on contacts in the speed bar, the contacts box link stays highlighted, which will make the menu more user-friendly. At first I thought this could be done with the active link property in CSS, but unfortunatelly it can't. So I've searched google and found out a way, but I'm not quite sure how to integrate this with X-Cart, so what we should do is assign id for the body of each page we have link to in the speed bar like this:

Code:

<body class=■home■>

And after that for each link we must add a custom class like this:

Code:

<ul>
  <li><a href=■home■ class=■home■>Home</a>
  <li><a href=■articles.html■ class=■articles■>Articles</a>
  <li><a href=■blog.html■ class=■blog■>Blog</a>
  ┘ etc┘
  </ul>



And then we must add the custom classes in our CSS like this:


Code:

body.home a.home, body.articles a.articles, body.blog a.blog {
  background-color: green;
  }


That sounds reasonable when we are dealing with HTML, but how to do this with X-Cart and Smarty. I really need this one and it is a feature, that everybody will enjoy. Can someone point me out to the right files that we need to edit and tell me how to adapt the code to use with this great shopping cart system?

cflsystems 05-03-2010 04:38 PM

Re: Highlight current page in speedbar
 
Use $main, $help_section and $page_data and define css style "current" or wnatever you want to call it

{if $main eq "...."}, {if $help_section eq "contactus"}, {if $page_data.pageid eq "...."}

Something like this

<a href=""{if $help_section eq "contactus"} class="current"{/if}>Contact Us</a>
<a href=""{if $page_data.pageid eq "5"} class="current"{/if}>Skin Care</a>

FTI 05-04-2010 04:55 AM

Re: Highlight current page in speedbar
 
Thank you, Sir. But in which file I should put this, and also all the links in my speed bar are links to categories in my site. So I'll be glad if you point me to the right file. Thanks in advance!

cflsystems 05-04-2010 07:28 AM

Re: Highlight current page in speedbar
 
These will be your links so where you want them to appear thats where you put them. Not sure right now what the template for the speed bar links was called but if you look in head,tpl you should be able to find it. If links are based on categories you can use

{if $current_category.categoryid eq "xxx"}

FTI 05-10-2010 08:47 AM

Re: Highlight current page in speedbar
 
I can't find the speedbar links. I got as far as tabs.tpl:

Code:

{*
$Id: tabs.tpl,v 1.2 2009/04/21 11:42:00 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $speed_bar}
  <div class="tabs">
    <ul>
      {foreach from=$speed_bar item=sb name=tabs}
        <li{interline name=tabs}><a href="{$sb.link|amp}">{$sb.title}</a></li>
      {/foreach}
    </ul>
  </div>
{/if}


cflsystems 05-10-2010 12:35 PM

Re: Highlight current page in speedbar
 
These are the speed bar links. They are in an array called $speed_bar and the templates just loops trhough them. Put the if statement inside the <a>

FTI 05-11-2010 06:22 AM

Re: Highlight current page in speedbar
 
Code:

{*
$Id: tabs.tpl,v 1.2 2009/04/21 11:42:00 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $speed_bar}
  <div class="tabs">
    <ul>
      {foreach from=$speed_bar item=sb name=tabs}
        <li{interline name=tabs}><a href="{$sb.link|amp}"{if $current_category.categoryid eq "xxx"}>{$sb.title}</a></li>
      {/foreach}
    </ul>
  </div>
{/if}


Something like this? How I should apply this for all of the 7 links and I know it sounds stupid but how can I get the category ID :) Thank you man, you are the one who is helping me since my fist post in this forum. I appreciate it, too bad I can't help you a lot with my poor knowledge...

ARW VISIONS 05-11-2010 07:14 AM

Re: Highlight current page in speedbar
 
you can get the cat id in the admin section.

just click on the cat and then the id will show in the URL

cflsystems 05-11-2010 09:41 AM

Re: Highlight current page in speedbar
 
Quote:

Originally Posted by FTI
Code:

{*
$Id: tabs.tpl,v 1.2 2009/04/21 11:42:00 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $speed_bar}
  <div class="tabs">
    <ul>
      {foreach from=$speed_bar item=sb name=tabs}
        <li{interline name=tabs}><a href="{$sb.link|amp}"{if $current_category.categoryid eq "xxx"} class="current"{/if}>{$sb.title}</a></li>
      {/foreach}
    </ul>
  </div>
{/if}


Something like this? How I should apply this for all of the 7 links and I know it sounds stupid but how can I get the category ID :) Thank you man, you are the one who is helping me since my fist post in this forum. I appreciate it, too bad I can't help you a lot with my poor knowledge...

See above in red. You can get the catid from admin - open categories, point to the category in question - it is in the url or you can export categories and look in the csv file. The foreach loops through all speed bar links and will apply class current to the item only if that item in the loop is matching the if statement

FTI 05-24-2010 06:36 AM

Re: Highlight current page in speedbar
 
Thank you so much, that did the job! :)

PS: Is there a way to assign this current class to all subcategories in the main category, cause the highlighting disappears when I go into a subcategory?

cflsystems 05-24-2010 08:27 AM

Re: Highlight current page in speedbar
 
{if $current_category.categoryid eq "xxx" || $current_category.parentid eq "xxx"} class="current"{/if}
Not sure on top of my head if it's "parent", "parentid", or "paren_category"

FTI 05-24-2010 11:04 AM

Re: Highlight current page in speedbar
 
Thanks, again Steve. This was extremely helpful, is there any way this to be done for the sub-sub categories without writing a whole bunch of numbers?

Take a look

cflsystems 05-24-2010 12:49 PM

Re: Highlight current page in speedbar
 
Not sure but there is probably a way

ARW VISIONS 05-24-2010 12:59 PM

Re: Highlight current page in speedbar
 
{if $current_category.categoryid_path|regex_replace:" /\/[0-9\/]*/":""}class="current"{/if}

This should work

FTI 05-24-2010 02:38 PM

Re: Highlight current page in speedbar
 
Thanks Ash, where to put the category ID?

ARW VISIONS 05-24-2010 05:09 PM

Re: Highlight current page in speedbar
 
{if $current_category.categoryid_path|regex_replace:" /\/[0-9\/]*/":"" eq "259"}class="current"{/if}

FTI 05-30-2010 07:57 AM

Re: Highlight current page in speedbar
 
Thaht did a perfect job. Ash, you are awesome. You and Steve, figured out the whole thing for me. Thanks guys! :)

ARW VISIONS 05-30-2010 10:55 AM

Re: Highlight current page in speedbar
 
no problem, glad I could help.

Ajay 06-06-2010 03:25 PM

Re: Highlight current page in speedbar
 
I want to remove the link on the tab, when same page is being viewed. So I made this change to skin1/customer/head.tpl . This is in 4.2.x
Quote:

<div class="tabs">
<ul>
{foreach from=$speed_bar item=sb}
{if $smarty.server.REQUEST_URI|replace:"/shop/":"" eq $sb.link }
<li class="current" >{$sb.title}</li>
{else}
<li><a href="{$sb.link|amp}">{$sb.title}</a></li>
{/if}
{/foreach}
</ul>
</div>


And then you can change the color of .current class as you wish

believein 06-28-2011 02:59 AM

Re: Highlight current page in speedbar
 
Is there a way of doing this to highlight using the page Id for static pages?

ARW VISIONS 06-28-2011 04:33 AM

Re: Highlight current page in speedbar
 
NOt exactky sure what you want to accomplish. What do you mean highlight??

believein 06-28-2011 04:52 AM

Re: Highlight current page in speedbar
 
Hi,

For example when on the FAQ's (static) page I'd like to make the link in the main nav have a light green background. Perhaps by adding a class to the link and using CSS to style its background.

Please look at my link. http://www.urlgone.com/0feb23/

ARW VISIONS 06-28-2011 05:16 AM

Re: Highlight current page in speedbar
 
ok gotcha. Yes there is a way.

{if $page_data.pageid = '2'}class="current"{/if}

replace the 2 with your faq page id class.

believein 06-28-2011 05:33 AM

Re: Highlight current page in speedbar
 
Thanks ARW VISIONS.

But that applies the class to all the links — as the if statement is true each time the loop that generates the menu is cycled through.

I would like just the link that applies to the current to have the class.

ARW VISIONS 06-28-2011 07:51 AM

Re: Highlight current page in speedbar
 
ok how about this....

{if $page_data.pageid eq '2' && $sb.title eq 'Test'}style="color:#cc0000"{/if}

replace with your data.

ARW VISIONS 06-28-2011 08:04 AM

Re: Highlight current page in speedbar
 
{if $page_data.title eq $sb.title}style="color:#cc0000"{/if}
would work for all static pages as long as the page title and the speed bar title are the same.

believein 06-28-2011 08:43 AM

Re: Highlight current page in speedbar
 
Quote:

Originally Posted by ARW VISIONS
ok how about this....

{if $page_data.pageid eq '2' && $sb.title eq 'Test'}style="color:#cc0000"{/if}

replace with your data.


This seems to do the trick. Thank you very much.

Going to be a bugger if the client renames the pages though!

I thought this sort of functionality would be a standard feature for designers to latch onto.

Maybe Ill suggest as a feature request.

Thanks again.

believein 06-28-2011 08:51 AM

Re: Highlight current page in speedbar
 
Ok - now I have to feature out the dynamic pages Eg. Contact

help.php?section=contactus

Do these page types have ID or titles?

cflsystems 06-28-2011 09:12 AM

Re: Highlight current page in speedbar
 
You can use "main" and "section" for help pages

ARW VISIONS 06-28-2011 10:00 AM

Re: Highlight current page in speedbar
 
{if $page_data.title eq $sb.title}style="color:#cc0000"{/if} if u do this, the as long as speed bar title and page title match its good.

believein 06-30-2011 05:46 AM

Re: Highlight current page in speedbar
 
{if $main eq "catalog" && $sb.title eq 'Shop'} class="current"{/if}

Seems to do the trick. Thank you all!


All times are GMT -8. The time now is 12:53 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.