Jump to content

conditional CSS links


Recommended Posts

In the category-tree-branch.tpl there is a conditional style element attached to the links, via




So when the current link is on, the menu item gets the selected style via conditional code {if $node.id == $currentCategoryId}

I would like to do that to my CMS pages/info menu links too, but I cant get it to work.

This is what i am trying:

{foreach from=$cmslinks item=cmslink}
{$cmslink.meta_title|escape:htmlall:'UTF-8'}
{/foreach}



I have no idea what variables to use here, but $node.id == $cmslink.id doesnt work.

Anybody?

thanks Robbin

Link to comment
Share on other sites

Unfortunately, it is not quite that simple. You need to modify modules/blockinfos/blockinfos.php and add this code just before line 110 (the call to blockinfos.tpl):

$smarty->assign('currentId', $_GET['id_cms']);



then you can write this in blockinfos.tpl:

{foreach from=$cmslinks item=cmslink}
{$cmslink.meta_title|escape:htmlall:'UTF-8'}
{/foreach}

Link to comment
Share on other sites

  • 1 month later...

ah this was so promising. I tried this but it didn't work. i have my info block in my left side column. i would also like the "selected" condition to apply, but i can't get it to work. is there something different that must be done if it's in the left side menu?

many thanks.

Link to comment
Share on other sites

  • 7 months later...

I know this is an old thread, but I just had to do this for a client and found a solution. I changed lines 107 of modules/blockinfos/blockinfos.php from:

$smarty->assign('cmslinks', $id_cms ? CMS::getLinks($cookie->id_lang, $id_cms) : array());



to:

for ($i = 0; $i < sizeof($cmsLinks); $i++)
   $cms[$i]['link'] = $cmsLinks[$i]['link'];
$smarty->assign('cms', $cms);



then line 5-6 of modules/blockinfos/blockinfos.tpl from:

{foreach from=$cmslinks item=cmslink}
{$cmslink.meta_title|escape:html:'UTF-8'}



to:

{foreach from=$cms item=item}
{$item.meta_title|escape:html:'UTF-8'}



then I added the following to the /* Block CMS links */ section of global.css:

#informations_block_left li.selected a { color: blue }



Change blue to whatever colour you want the link to the current CMS page to be.

Link to comment
Share on other sites

  • 5 months later...

Hi Rocky,

it works 93 percent for me :) When i manualy (browser address) go to one of the cms pages the color is changing accordingly to my css. The links itself in the infoblock are not present (href is empty " " in the code) only the text. Any ideas?

Ver. 1.3.2.3

thank you in advance

H.

Link to comment
Share on other sites

Yes, i did exactly as you adviced. Everything is working fine except the links.

best

H.

the code i get f.e. for going manualy to zahlung-versand-garantie is:

.....

Information

Zahlung - Versand - Garantie
 Impressum
.....



from line 102 blockinfos.php now looks like:

   
.....
function hookLeftColumn($params)
   {
       global $smarty, $cookie;

       $cms = CMS::listCms($cookie->id_lang, $this->id);
       $id_cms = array();
       foreach($cms AS $row)
           $id_cms[] = intval($row['id_cms']);
       for ($i = 0; $i < sizeof($cmsLinks); $i++)
   $cms[$i]['link'] = $cmsLinks[$i]['link'];
$smarty->assign('cms', $cms); 
       return $this->display(__FILE__, 'blockinfos.tpl');
   }
.....




and blockinfos.tpl like:

<!-- Block informations module -->

{l s='Information' mod='blockinfos'}

       {foreach from=$cms item=item}
{$item.meta_title|escape:html:'UTF-8'}
       {/foreach}
 

<!-- /Block informations module -->



and Information Block is hooked in left column

Link to comment
Share on other sites

  • 2 weeks later...

... in my case changing

{foreach from=$cmslinks item=cmslink}
{$cmslink.meta_title|escape:htmlall:'UTF-8'}
       {/foreach}



to

{foreach from=$cmslinks item=cmslink}        
{$cmslink.meta_title|escape:htmlall:'UTF-8'}
       {/foreach}



in productinfos.tpl did the trick ( a professional helped me)

no changes in blockinfos.php

best

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...