Section header link - how to?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Section header link - how to?

Post by jakovbak »

Hello everyone!
I'm trying to do something with my navigation but I'm not very familiar with Smarty so I ended up 'in the middle of nowhere'. Maybe someone could help me out...
I'm using minimal_menu and I would like to change the behaviour of section headers to act like links to its own first child page. This is the part of the minimal_menu dedicated to section headers:

Code: Select all

      <li class="sectionheader{if $node->parent} activeparent{/if}">
        {$node->menutext}
        {if isset($node->children)}
          {include file=$smarty.template nodes=$node->children depth=$depth+1}
        {/if}
      </li>
As far as I can understand, the second line - {$node->menutext} - should be altered and wrapped up in <a> tag which points to the desired child page (or something similar to that).
I can wrap it up in link tag but I have no ideas left what syntax to use to get what I need! And I have tried many, many solutions...

Thank you in advance for ideas or help of any kind!

Best regards,
jakovbak
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Section header link - how to?

Post by velden »

You are aware that this functionality is built in already?

Add New Content -> Content type: Internal Page link.

But to set it up, you either need to create this Internal Page link first and point it to some existing page. Then create the children pages and finally change the link to one of those childs.

Or create the first 'child' page first, set it in the root. Then create the Internal Page link to this 'child' page. And finally change the parent setting of this childpage.

Clear? :-)

I like your idea of the automatic link thing though.

Quickly tested:

Code: Select all

      <li class="sectionheader{if $node->parent} activeparent{/if}">
        {if isset($node->children)}
           {* <!-- {$node->children|print_r} --> *} {* <-- uncomment this to see what options you have (in html source) *}
           <a href="{$node->children.0->url}">{$node->menutext}</a>
        {else}    
          {$node->menutext}
         {/if}
        {if isset($node->children)}
          {include file=$smarty.template nodes=$node->children depth=$depth+1}
        {/if}
      </li>
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: Section header link - how to?

Post by jakovbak »

Hello Velden!
I have tried Internal page link but not in the order you described, so obviously, in final step I wasn't able to point it to child page because it wasn't in the root! Maybe this option is less 'user friendly' as it should be... :-)
On the other hand, it did make think outside of the box and it's a good thing, right?
I'm not at computer right now but I'll give it a try when I get home along with the code you provided and get back to you with the results. And I won't close this topic yet because this menu should be responsive too (based on Bootstrap) and I expect more tweaking to make it look properly in responsive mode.
Thanks again and best regards!
Jakovbak
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Section header link - how to?

Post by velden »

Changed the code a little.

Code: Select all

<li class="sectionheader{if $node->parent} activeparent{/if}">
        {if isset($node->children)}
           {* <!-- {$node->children|print_r} --> *} {* <-- uncomment this to see what options you have (in html source) *}
           <a href="{$node->children.0->url}">{$node->menutext}</a>
          {include file=$smarty.template nodes=$node->children depth=$depth+1}
        {else}   
          {$node->menutext}
         {/if}
      </li>
Further note that the code doesn't check for the type of content of the first child. It could as well by another section header or whatever. Then things might go wrong.
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: Section header link - how to?

Post by jakovbak »

Good to know. However, in this particular case it would be used only as a link to the first child page. In other cases, I will use built-in option but in this one, I don't want to waste a good and clean piece of code...
;D
Regards,
Jakovbak
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: Section header link - how to?

Post by jakovbak »

Hello again!
Unfortunately, it all went 'down south'... Everything was ok until third level came along and then the whole thing broke. Here's a quick sketch of the idea behind this menu:

(menu 1st row/level)
INT.PAGE LINK 1 - INT.PAGE LINK 2 - INT.PAGE LINK 3 - ... (visible)
(menu 2nd row/level)
IPL1 CHILD 1 - IPL1 CHILD 2 - IPL CHILD 3 - ... (visible)
(or IPL2 CHILD1 - IPL2 CHILD2 - ... if 'active page' is INT.PAGE LINK 2 etc)
(menu 3rd level)
CHILD1child1 - CHILD1child2 - CHILD1child3 - ... (dropdown)

So far I was very satisfied with Bootstrap's ability of integration with CMSMS and I have decided to stick with the platform in this case too. But if you Velden or anyone else comes up with a suggestion how to deal with this by using another responsive techniques and platforms - please, you're more than welcome!

Here is the rough draft of the menu (minimal_menu template is used with first <ul> commented out to fit Universal theme menu construction):

http://www.adriaticsolution.hr/index.php?page=marine

(second 'MARINE' is actually a first child of internal page link of the same name!)

Thank you in advance and have a nice weekend!
Best regards,
Jakovbak
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Section header link - how to?

Post by velden »

Here is the rough draft of the menu (minimal_menu template is used with first <ul> commented out to fit Universal theme menu construction):
That could very well be a/the problem. You can't do that because you will be using (probably) the same template for every level. So removing it from the template, will prevent it to set the second and third level <ul>

The Navigator module and templates are very flexible and I'm pretty sure they can create any logical menu structure needed for frameworks.
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: Section header link - how to?

Post by jakovbak »

Ok. I was unaware of the fact. Now the <ul> is back, what can I do next?
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

[CLOSED] Re: Section header link - how to?

Post by jakovbak »

Since there was no new suggestions and I had to move on with the site, I had to improvise a bit and to rethink the navigation. Didn't find the solution to this topic but at least my navigation looks like it was imagined for desktops and almost as it supposed to look like on small devices. It takes some work on CSS for small devices but you can check the rest of it on desktop if you are interested here:

http://www.adriaticsolution.hr/index.php?page=marine

Thank you once again and best regards!
Jakovbak
Post Reply

Return to “The Lounge”