ycorde Posted October 19, 2011 Share Posted October 19, 2011 Hi, Is it possible when you click on a cms category to open the first cms page instead of having first an overview of all the pages For example If I click on the first cms category in my navigation bar I become: http://www.maselecti..._cms_category=3 The thing I want is the obtain the first cms page, in this case 'Qui est Marie Melodie' http://www.maselecti...s.php?id_cms=23 This my code of the blockcategories.tpl <ul id="main-nav"> {foreach from=$cms_titles.categories item=cms_category} <li><a class="main-link" href="{$cms_category.link}">{$cms_category.name}</a> <ul class="sub-links"> {foreach from=$cms_titles.cms item=cms_page} {if $cms_category.id_cms_category eq $cms_page.id_cms_category} <li><a href="{$cms_page.link}">{$cms_page.meta_title}</a></li> {/if} {/foreach} </ul> </li> {/foreach} {foreach from=$blockCategTree.children item=child name=blockCategTree} <li><a class="main-link" href="{$child.link}">{$child.name}</a> {if count($child.children) gt 0} <ul class="sub-links"> {foreach from=$child.children item=sub_child} <li><a href="{$sub_child.link}">{$sub_child.name}</a></li> {/foreach} </ul> {/if} </li> {/foreach} <li><a class="main-link" href="{$base_dir}stores.php">{l s='Magasins'}</a></li> <li><a class="main-link" href="{$base_dir}blog">{l s='Blog-Creation' module='blockcategories'}</a></li> Thanks in advance Jack Link to comment Share on other sites More sharing options...
flamedtofu Posted November 20, 2013 Share Posted November 20, 2013 (edited) did you ever work this out Ycorde? I'm trying to do the same thing as the CMS category page is too ugly and kind of unneeded for my purposes. I did think of either using a mod rewrite in ht access? or perhaps creating a folder with the same path name and puting an index.html file in it with a redirect script - although i'm not sure which would take preference? Edited November 20, 2013 by flamedtofu (see edit history) Link to comment Share on other sites More sharing options...
NassNus Posted October 3, 2016 Share Posted October 3, 2016 (edited) Hello you can do this in init method of your override files on CmsController.php parent::init(); if ($id_cms = (int)Tools::getValue('id_cms')){ $this->cms = new CMS($id_cms, $this->context->language->id); }else if ($id_cms_category = (int)Tools::getValue('id_cms_category')){ if((int)$id_cms_category == Your-Parent-CMS-Categorie){ $link = new Link(); Tools::redirectLink($link->getCMSLink(Your-first-Child, null,null, $this->context->language->id)); }else{ $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id); } } Nassim Edited October 3, 2016 by NassNus (see edit history) Link to comment Share on other sites More sharing options...
fixgear Posted October 5, 2017 Share Posted October 5, 2017 Hi Nassim.If you see this, can you tell me exactly what code in CmsController.php to change and where to add the page I want to redirect to? I tried to paste what you provided above but it breaks my site.Thanks!Jeremy... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now