Highlight viewed page in the information block

Today I want to show you how to highlight viewed CMS page in the information block. By default block cms module doesn't allow to highlight viewed page. In this case modification is necesary. I will show you step by step how to achieve this effect. We will edit the default cms block prestashop module and we will create special css style for "highligh" effect. You can check how it will looks like on the picture below.

 

Highlighted CMS page in the information block

highlight viewed cms page prestashop

 

1. The default module tempalte file modification

As I said we have to edit default prestashop module: CMS block. This addon allows you to create blocks with links to the CMS pages defined in your store in the preferences > CMS tool. Default information block is a part of this module. Open please the file:

/modules/blockcms/blockcms.tpl remember that this file is sometimes overrided by template files. By default it is. So you have to to open the file: /themes/modules/blockcms/blockcms.tpl. You've got there something like:

<!-- Block CMS module -->
	{foreach from=$cms_titles key=cms_key item=cms_title}
		<div id="informations_block_left_{$cms_key}" class="block informations_block_left">
			<h4 class="title_block"><a href="{$cms_title.category_link}">{if !empty($cms_title.name)}{$cms_title.name}{else}{$cms_title.category_name}{/if}</a></h4>
			<ul class="block_content">
				{foreach from=$cms_title.categories item=cms_page}
					{if isset($cms_page.link)}<li class="bullet"><b style="margin-left:2em;">
					<a href="{$cms_page.link}" title="{$cms_page.name|escape:html:'UTF-8'}">{$cms_page.name|escape:html:'UTF-8'}</a>
					</b></li>{/if}
				{/foreach}
				{foreach from=$cms_title.cms item=cms_page}
					{if isset($cms_page.link)}<li><a href="{$cms_page.link}" title="{$cms_page.meta_title|escape:html:'UTF-8'}">{$cms_page.meta_title|escape:html:'UTF-8'}</a></li>{/if}
				{/foreach}
				{if $cms_title.display_store}<li><a href="{$link->getPageLink('stores')}" title="{l s='Our stores' mod='blockcms'}">{l s='Our stores' mod='blockcms'}</a></li>{/if}
			</ul>
		</div>
	{/foreach}
	<!-- /Block CMS module -->

we are interested in highlighted line with definition of the link - ther are visible in the informations block. We have to edit it. We must add there class="" definition which will inform that page is viewed in browser. So, here is the code, this line should looks like:

{if isset($cms_page.link)}<li {if isset($smarty.get.id_cms)}{if $smarty.get.id_cms == $cms_page.id_cms} class="selected" {/if}{/if}><a href="{$cms_page.link}" title="{$cms_page.meta_title|escape:html:'UTF-8'}" >{$cms_page.meta_title|escape:html:'UTF-8'}</a></li>{/if}

Let me describe what I added. Into the <li> object I added two {if} conditions - first checking browsing page, if the page is created in the CMS tool, then next {if} condition checking the id of CMS page. If viewed cms id page = clicked element id - then the li element will have the css class="selected".

{if isset($smarty.get.id_cms)} // first if condition
    {if $smarty.get.id_cms == $cms_page.id_cms}  // second if condition
        class="selected" // our class="" definition
    {/if} // second if condition close tag
{/if} // first if condition close tag

 

 Define CSS styles for higlight effect

Now it's time for customization of the highlight effect. In this case we have to create .selected class in the global.css file. in this case we will edit main css file of the theme. Go to the themes/your_theme/css/global.css. Just paste somewhere code that I created for achieve highlight effect.

 

the styles for hoover and highlight efect looks like

.informations_block_left li a:hover,  .informations_block_left li.selected a{
    display:block;
    padding:7px 11px 5px 22px;
    color: #000000;
    text-shadow: 0 1px 0 #f5da2c;
    background: #f7b900 url(../../../modules/blockcms/img/arrow_right_2.png) no-repeat 10px 10px!important;
}

 Of course you can customize it, you can define own font color, own background etc. Just use the power of the CSS. That's all. Just save changes. Make sure that you've got force compilation turned to on (template file needs recompilation) and that you've got CCC turned to off (minifed css file needs it too). If you've got any questions or concerns related to this tutorial - I'm waiting for your comments below.

 

author milos myszczuk
Article by Milosz Myszczuk PrestaShop expert, official PrestaShop community moderator. PHP developer, specialist in relative and spatial databases management, GIS Analyst, CEO & founder of VEKIA interactive agency. Read more about VEKIA company
If you like my articles and want much more valuable tips, feel free to send me donation
1.4 version 1.4.11 1.6 404 addon admin advertise ahref ajax alpha animation api app application authentication back office backup badge banner basics block bootstrap button cache carrier cart catalog category certificate changelog chat class clear client clip cms code colors columns comments configuration contact container content controller cookie counter country coupon css csv currency customer dashboard database debug default delete delivery desktop developer device disable discount displayNav displayTop download dynamic editor effect empty encrypt engine error exchange exclude export facebook faceshop fade fancoupon fancybox fanpage fatal feature feed field file fix fixed font footer free friendly url front ftp full gallery generate gift global godaddy google google+ gray grid groupon header help hide highlight homefeatured homepage hook hosting hover howto htaccess html html5 ID image import include input instagram installation integration iPhone issue javascript jquery kgb knowhow languages law left likebox link list livingsocial loading log login logo loyality mail mailing maintenance manufacturer marketing marquee mcrypt menu meta mobile modification module movie moving multilanguage multiupload must have mysql news newsletter notification number open graph order override page password performance PHP phpmyadmin picture pinterest plugin popup post prestashop prestashop 1.0 prestashop 1.1 prestashop 1.2 prestashop 1.3 prestashop 1.4 prestashop 1.5 price rules problem product profile promotion proslider purifier quantity query quick tip random rates register reinsurance release reporting reset responsive restore results ribbon rich text right sales search security seo service shadow share shipping shop shopmania slider smarty social networks SQL SSL statistics stock store style subcategory superuser support switcher tab tablet tag tax template text theme tinyMCE tips and tricks tpl tracking translations tree trends trigger tumblr tutorial twitter update upgrade upload variables video visits voucher vulnerability web2print wide widget width window wishlist wysiwyg youtube zip zopim