exampleHeaderLinks.php, modifyHeaderLinks.php. header_links no longer working in 3.+, stuck at 2.6+

6 posts by 2 authors in: Forums > CMS Builder
Last Post: September 11, 2018   (RSS)

By daniel - September 6, 2018

Hi Jerry,

If you check out the latest version of the Modify Header Links plugin (https://www.interactivetools.com/add-ons/modify-header-links/) it should contain new examples for how to modify header links in CMSB v3.

Let me know if you have any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By gkornbluth - September 6, 2018 - edited: September 6, 2018

Thanks Daniel,

I had found an old version of the modifyHeaderLinks plugin, but didn't see this new one for some reason...

I do have a question. (actually a few) regarding creating the arrays. (I'm not too knowledgeable about this)

1) If I had a series of links that I wanted to show at the beginning, lets say:

<a target='_blank' href='http://pixlr.com/express/'>The Free Pixlr On-Line Image Editors &gt;&gt;<br /></a>
<a target='_blank' href='http://www.elleschorrphotography.com/using-pixlr.php'>How to Use Pixlr Express &gt;&gt;<br /><br /></a>

How would I modify the code to accomplish this?

2) How would I set the following code to TRUE

'isSelected' => (@$_REQUEST['menu'] == 'new_menu'), // set to true to show this menu as selected

3) Would I add another series of links to the end in a similar way by creating a $newmenu2 array and then changing array_push($menuArray, $newMenu); to array_push($menuArray, $newMenu2);

Sorry I'm so confused, and thanks for looking at this.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Attachments:

modifyHeaderLinks.php 3K

By daniel - September 7, 2018 - edited: September 7, 2018

Hi Jerry,

1) If I had a series of links that I wanted to show at the beginning, lets say:
3) Would I add another series of links to the end in a similar way by creating a $newmenu2 array and then changing array_push($menuArray, $newMenu); to array_push($menuArray, $newMenu2);

For adding these external links at the beginning, you would use something like this:

$newMenu = [
  'menuName' => 'The Free Pixlr On-Line Image Editors &gt;&gt;',
  'menuType' => 'custom',
  'link' => "http://pixlr.com/express/",
  'isSelected' => false,
  'linkTarget' => '_blank',
  'visibility' => 'showAlways',
  'br_after' => true,
];
array_unshift($menuArray, $newMenu);

$newMenu = [
  'menuName' => 'How to Use Pixlr Express &gt;&gt;',
  'menuType' => 'custom',
  'link' => "http://www.elleschorrphotography.com/using-pixlr.php",
  'isSelected' => false,
  'linkTarget' => '_blank',
  'visibility' => 'showAlways',
  'br_after' => true,
];
array_unshift($menuArray, $newMenu);

As you can see, you can keep using the $newMenu variable name - simply call either array_unshift($menuArray, $newMenu) (add to the beginning) or array_push($menuArray, $newMenu) (add to the end) after each option array definition to add it to the menu.

2) How would I set the following code to TRUE

This is only necessary for links that point to pages within CMSB and is mostly done automatically. You would just need to make sure that the value in that line matches the "menu=" value in the link option. For example:  

'link' => "?menu=example",
'isSelected' => (@$_REQUEST['menu'] == 'example'),
     

Let me know if there's anything else I can help with.  

Thanks,

Daniel
Technical Lead
interactivetools.com

Thanks Daniel,

Makes much more sense now.

I'll write this up and share it as a recipe in my CMSB Cookbook.

Don't know if you've  had a chance to look over the cookbook. When you do i would appreciate any suggestions.

I'll look out for your free trial membership ( http://www.thecmsbcookbook.com/trial.php ) and convert it to a complementary lifetime membership as I have for everyone else at Interactive Tools.

Welcome to the group.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hey Jerry,

I've just signed up, I'll definitely check it out when I've got some time.

Thanks!

Daniel
Technical Lead
interactivetools.com