Jump to content

[Solved] How To Show A Specific Block In The Left Column Depending On The Page I Am


Recommended Posts

In the old 1.4.7.3 PS version to show a specific block in the left column depending on the page i am, i used to insert in the .tpl of the block the following javascript  array (for cms pages)

 if $page_name == 'cms' AND $smarty.get.id_cms}
        {if in_array($cms_class,    
array(154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183))}
            {$content}        
        {/if}
    {/if}

now i'm trying to do the same on the new PS 1.6.0.14, but unfortunatly it doesn't work, i search the forum for a solution or a suggestion to come to the point without results.

 

Anyone can help me suggesting what i have to change in that code to make it work?

 

Any help is welcome!

 

 

Edited by ariom (see edit history)
Link to comment
Share on other sites

You know the hook function in Prestasop 1.6. ? Go to modules > positions > on top green nav bar > move a module and you can on the next page set the behaviour of your modules (blocks) on the specific pages by using restrictions on the pages selected on bigger block there.

Edited by selectshop.at (see edit history)
Link to comment
Share on other sites

thanks for your suggestion...

i know what you are talking about, but i'm looking for a different thing,

 

i Have 200 cms pages in 6 categories, for ten of them i want a specific module on the left column, for other 25 cms page i want a totally different module and not the first one, and so on....

 

with hook function i can only view all this modules in all cms pages, i'm looking for the right js code to conditionally select an array of specific cms pages by their id to show one module, another array of cms pages by their id for another module and so on ...

 

before i used that js code in my first post, but with 1.6 it's not working.

 

Thanks for helping and sorry for my english...

Link to comment
Share on other sites

Ok, i solved myself, here how i did:

 

1) Create a file named FrontController.php in override/classes/controllers (if you already have it, you need to merge with your) and copy inside the following code (to get in the context the variable id_cms from the db)

    public function init()
    {	
        $id_cms = array();		
        parent::init();	
        $id_cms = (int)Tools::getValue('id_cms');			
        $this->context->smarty->assign(array('id_cms' => $id_cms));
    }

2) insert (in the module template file) an array of all the id for the cms pages in wich i want my modules to be shown in the left column  (or any other hook i want, the variable it is now accessible from any cms page defined in the array):

{if $page_name == 'cms' && $smarty.get.id_cms} 
    {if in_array($id_cms, array(154,155,156,157,158))}
        <!-- Here is your module content -->
    {/if}
{/if}

That's all, hope someone else who need will enjoy it

Edited by ariom (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

Anyone know how i can modify blocks' module for different cms pages? For blogs' module I say "categories", "products viewed", " events ecc..anyone can help me?

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...