Jump to content

Change URL link for CMS Home in Top Menu


Recommended Posts

I've been struggling with a modification on the top menu of a PS 1.5.6 store. We'd like to use the CMS home directory but rather than having "home" link to the CMS home page (/index.php?id_cms_category=1) have it link to the base or index page as the catalog "home" link.

 

Is this possible? I appreciate any assistance you can send my way!

Thanks,

JS

Link to comment
Share on other sites

Hi,

 

The problem you are facing is you are adding Home from the CMS page. In order to link to your home page you can either use :

 

 

Home from Category like the one below:

post-732514-0-52270500-1385783055_thumb.png

 

Or you can create a new Menu Top link like this and then add to the menu:

post-732514-0-77063800-1385782973_thumb.png

 

Hope this helps.

  • Like 1
Link to comment
Share on other sites

Thanks, but the category home page drops down to the product categories. We want to have one menu item that links to the index and drops down to the CMS pages.

 

I could put a static home button to link to the index and another that drops to CMS but would rather eliminate the need for two separate menu items.

 

So instead of

 

Home (index)

 - category 1

 - category 2

 - category 3

 

or

Home (cms)

 - cms 1

 - cms 2

 - cms 3

 

We'd like it to list as this:

 

Home (index)

 - cms 1

 - cms 2

 - cms 3

 

Any suggestion on how this might be possible?

thanks again,

js

 

Link to comment
Share on other sites

This is how you custom code. In modules/blocktopmenu/blocktopmenu.php look for method private function makeMenu()

 

makeMenu is the method that builds your menu. There is a switch case in that method. Look for 

case 'CMS_CAT':
    $category = new CMSCategory((int)$id, (int)$id_lang);
    if (count($category))
    {
        $this->_menu .= '<li><a href="'.$category->getLink().'">'.$category->name.'</a>';
        $this->getCMSMenuItems($category->id);
        $this->_menu .= '</li>'.PHP_EOL;
    }
break;

The Home CMS category is always 1 so I am going to write a code that will replace the URL of cms_category_1 to shop base url like this :

case 'CMS_CAT':
    $category = new CMSCategory((int)$id, (int)$id_lang);
    if (count($category))
    {
        if($category->id === 1){
	    $this->_menu .= '<li><a href="'.__PS_BASE_URI__.'">'.$category->name.'</a>';
	}else{
	    $this->_menu .= '<li><a href="'.$category->getLink().'">'.$category->name.'</a>';	
	}
	$this->getCMSMenuItems($category->id);
	$this->_menu .= '</li>'.PHP_EOL;
    }
break;

Hope this should work. This is quick fix. If you want to keep the code on upgrades then you have to use Module Overrides. Read this to get an idea : https://gist.github.com/JulienBreux/2287709

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hi ibndawood

 

I used your code and it worked great! Problem is now i need multiple cms sections on my menu, and i'm forced to this kind of situation:

 

Home (root category, not shown in menu)

  • Category1 (must be shown in the menu)

          - page 1

          - page 2

  • Category2 (no need to be shown in the menu)

          - page 3 (must be shown as a menu main item)

 

I want my Category1, which has ID=2, to link at homepage. I modified your code in the following way but it didn't worked:

if($category->id === 2)

It should do the trick but it doesn't! Am i missing something?

 

I am working on local so i am afraid i can't link to my site =(

 

Thanks!!

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

  • 2 months later...
  • 1 month later...
  • 4 months later...
  • 10 months later...
×
×
  • Create New...