Jump to content

Hide or show block in pages


Recommended Posts

Hi mardon

 

It is possible. What you should do is go to your Back Office, Under Modules>Positions>select your module from the combo box then you will see the hooks that your module is displayed. Let's assume that you will edit CMS block and that it is hooked on left column.

 

Select Left Column Blocks and click the edit icon next to your module name. Now to the exception field write the pages that you don't want the module to be displayed. Here the trick is that you have to write all other pages like index.php, order.php, product.php, etc.

 

Alternatively, you can use Smarty to hide the module code on every page but the one you want. For example, to show a module only on the homepage, add the following to the top of the module's TPL file:

 

{if $page_name == 'index'}

 

For a CMS page like cms.php?id_cms=4 you should write to the top

 

{if $smarty.get.id_cms == 4}

 

Hope this helps.

 

Cheers ;)

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

  • 3 years later...

Hello

I saw your post ... perhaps you can help me

 

I  would like to manage displaying for 3  htmlmodule under their own category
 
module_name=htmlanimaux  be only displayed under  category 3
 module_name=htmlbienetre  be only displayed under  category 4
module_name=htmlmaisonjardin be only displayed under  category 13

 

Or hide 2 of them  when we are on the third category
I saw somewhere that we need to add smarty code into header 

How I can do that ?   thanks for your help

Link to comment
Share on other sites

Hello

I saw your post ... perhaps you can help me

 

I  would like to manage displaying for 3  htmlmodule under their own category

 

module_name=htmlanimaux  be only displayed under  category 3

 module_name=htmlbienetre  be only displayed under  category 4

module_name=htmlmaisonjardin be only displayed under  category 13

 

Or hide 2 of them  when we are on the third category

I saw somewhere that we need to add smarty code into header 

 

How I can do that ?   thanks for your help

 

Hi

 

You can do this following the below instructions:

 

1. Open each module's php file: htmlanimaux.php, htmlbienetre.php and htmlmaisonjardin.php

2. Find the regarding hook function (if the module is positioned at columns, hookRightColumn or hookLeftColumn, etc. )

3. There you'll see the smarty variable settings (something like $this->smarty->assign(array(....)

4. Add the below smarty variable in this array:

'categoryid' =>Tools::getValue( 'id_category' ),

5. Open the smarty template files of each module and add the below lines to the top:

 

For the htmlanimaux:

{if $page_name = category}
{if $categoryid == 3}

For the htmlbienetre:

{if $page_name = category}
{if $categoryid == 4}

For the htmlmaisonjardin:

{if $page_name = category}
{if $categoryid == 13}

6. Then add the below line to the bottom of each template:

{/if}{/if}

There you go!

Hi !

 

how can hide catergory in checkout ? 

I have buy module bankwirepro from myprest.eu and now is show category in checkout ?

XtQ9oil.png

 

Picture is not displayed.

Link to comment
Share on other sites

  • 4 years later...
On 5/17/2012 at 8:05 AM, MEG Venture said:

Hi mardon

 

It is possible. What you should do is go to your Back Office, Under Modules>Positions>select your module from the combo box then you will see the hooks that your module is displayed. Let's assume that you will edit CMS block and that it is hooked on left column.

 

Select Left Column Blocks and click the edit icon next to your module name. Now to the exception field write the pages that you don't want the module to be displayed. Here the trick is that you have to write all other pages like index.php, order.php, product.php, etc.

 

Alternatively, you can use Smarty to hide the module code on every page but the one you want. For example, to show a module only on the homepage, add the following to the top of the module's TPL file:

 

 


{if $page_name == 'index'}
 

 

 

For a CMS page like cms.php?id_cms=4 you should write to the top

 

 


{if $smarty.get.id_cms == 4}
 

 

 

Hope this helps.

 

Cheers ;)

If i want to include all CMS pages? not just one page ID's? How we can do it. 

 

Thanks.

Link to comment
Share on other sites

Its a part of code on page.tpl into template folder.

Original code

  <section id="main">
    {block name='page_header_container'}
      {block name='page_title' hide}
      <h1 class="page-heading">{$smarty.block.child}</h1>
      {/block}
    {/block}

I want to do :

  <section id="main">
    {block name='page_header_container'}
      {if $smarty.get.id_cms > 0}
      	{else}
      	{block name='page_title' hide}
      	<h1 class="page-heading">{$smarty.block.child}</h1>
      {/if}
      {/block}
    {/block}

Is gonna work that way?

 

EDIT: No, it's breaking the page to load. :(

I just to to hide the <h1> object if smarty get id from CMS.

 

Edited by 8ternity (see edit history)
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...