Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Static links in menu  (Read 160 times)

MadsPH

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
Static links in menu
« on: February 20, 2013, 01:18:01 PM »

Hello! :)

I'm new to the forum. Cheers.

So far it's been great with pages, however I'd like to add some static links to my menu.

I have tried doing this, but then I get it at the end of the menu. I'd like to control the order in which the links appear.
It's essentially the same thing it's doing though.
Logged

MadsPH

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
Re: Static links in menu
« Reply #1 on: February 20, 2013, 01:30:27 PM »

I seem to have found it!
Code: [Select]
echo '<li><a'.$class.' href="'._SITE.'somepage/">'.l('pagelink').'</a></li>';
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Static links in menu
« Reply #2 on: February 20, 2013, 06:30:39 PM »

If you want your static link to get te class current when active, you should do the whole thing, like this:

Code: [Select]
$class = ($categorySEF == 'somepage') ? ' class="current"': '';
echo '<li><a'.$class.' href="'._SITE.'somepage/">'.l('pagelink').'</a></li>';
(See the other static links in pages() for reference.)

You should also add your static link names to the first part of $l['cat_listSEF'] to avoid conflicts:
Code: [Select]
$l['cat_listSEF'] = 'archive,contact,sitemap,login,somepage,otherpage,etc';
Logged

MadsPH

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
Re: Static links in menu
« Reply #3 on: February 20, 2013, 09:37:43 PM »

You should also add your static link names to the first part of $l['cat_listSEF'] to avoid conflicts:
Code: [Select]
$l['cat_listSEF'] = 'archive,contact,sitemap,login,somepage,otherpage,etc';

What is that? What does it do? Is the order in which they appear important?
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Static links in menu
« Reply #4 on: February 20, 2013, 11:10:22 PM »

$l['cat_listSEF'] is found in snews.php, relatively early in the file. It has two parts, one for public page SEF names and one for admin SEF names. What the list does is protect page names from conflicts, in other words makes sure that the listed link names remain unique. This is for "system" pages (for example content generated by a function, like archive or sitemap), or other link names you want to protect.

Example: let's say you add a forum system to your site, in a subfolder. In the page menu you would add the url "domain.tld/forum/" to access that forum system. Then you might write up a page about this forum and happen to call it "Forum". It also gets the url "domain.tld/forum/". Because the first is only a link and not an admin-created page or article, the system won't object to there being two links in the page menu with the exact same name, but a visitor will find it confusing, and clicking either of the two links will take you (the visitor) to the same place: the admin-created page, not the forum system.

So, if you instead add the forum system to the site, then add "forum" to the [public] cat_listSEF, that name/url is now protected. If you then try and create a page named "Forum", the system will force you to use a different page SEF.

As for order in the list: no, as far as I know it's not important.
« Last Edit: February 20, 2013, 11:13:12 PM by Fred K »
Logged

MadsPH

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
Re: Static links in menu
« Reply #5 on: February 21, 2013, 08:13:17 AM »

$l['cat_listSEF'] is found in snews.php, relatively early in the file. It has two parts, one for public page SEF names and one for admin SEF names. What the list does is protect page names from conflicts, in other words makes sure that the listed link names remain unique. This is for "system" pages (for example content generated by a function, like archive or sitemap), or other link names you want to protect.

Example: let's say you add a forum system to your site, in a subfolder. In the page menu you would add the url "domain.tld/forum/" to access that forum system. Then you might write up a page about this forum and happen to call it "Forum". It also gets the url "domain.tld/forum/". Because the first is only a link and not an admin-created page or article, the system won't object to there being two links in the page menu with the exact same name, but a visitor will find it confusing, and clicking either of the two links will take you (the visitor) to the same place: the admin-created page, not the forum system.

So, if you instead add the forum system to the site, then add "forum" to the [public] cat_listSEF, that name/url is now protected. If you then try and create a page named "Forum", the system will force you to use a different page SEF.

As for order in the list: no, as far as I know it's not important.

Thank you very much for the detailed information! I get it now!  :)
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Static links in menu
« Reply #6 on: February 21, 2013, 11:32:41 AM »

Hello! :)

I'm new to the forum. Cheers.

So far it's been great with pages, however I'd like to add some static links to my menu.

I have tried doing this, but then I get it at the end of the menu. I'd like to control the order in which the links appear.
It's essentially the same thing it's doing though.

Just adding to the menu list will not give you full control over the order.
Logged

MadsPH

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
Re: Static links in menu
« Reply #7 on: February 21, 2013, 02:49:01 PM »

Hello! :)

I'm new to the forum. Cheers.

So far it's been great with pages, however I'd like to add some static links to my menu.

I have tried doing this, but then I get it at the end of the menu. I'd like to control the order in which the links appear.
It's essentially the same thing it's doing though.

Just adding to the menu list will not give you full control over the order.

I wouldn't be able to put my page between the pages that sNews offer using the ui, but I would be able to manage it according to the other hardcoded pages, correct? :)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Static links in menu
« Reply #8 on: February 21, 2013, 03:03:04 PM »

... I would be able to manage it according to the other hardcoded pages, correct? :)

Correct.
Logged