sNews page navigation mod, a mod to hide pages from the navigation menu
This mod will add a checkbox to the "pages" interface in the admin area of your sNews 1.7 installation, like shown in the picture below. What this will do is allow you to create pages that won't be displayed in the pages() function call, yet they won't be hidden from viewing, you can still link to the pages manually.

To start, we need to add the appropriate field to the articles table in your database
ALTER TABLE articles ADD show_in_nav enum('YES','NO') default 'YES';
now BACK-UP your snews.php file work on a copy, now inside function pages, add the following highlighted code
$query = "SELECT id, seftitle, title FROM "._PRE.'articles'." WHERE position = 3 AND show_in_nav = 'YES' $qwr ORDER BY artorder ASC, id";
inside function form_articles, add the following highlighted code
$frm_showonhome = $r['show_on_home'] == 'YES' ? 'ok' : '';
$frm_show_in_nav = $r['show_in_nav'] == 'YES' ? 'ok' : '';
$frm_commentable = ($r['commentable'] == 'YES' || $r['commentable'] == 'FREEZ') ? 'ok' : '';
still inside function form_articles, add the following highlighted code
$frm_showonhome = s('display_new_on_home') == 'on' ? 'ok' : '';
$frm_show_in_nav = 'ok';
$frm_commentable = ($contents == 'extra_new' || $contents == 'page_new' || s('enable_comments') != 'YES') ? '' : 'ok';
still inside function form_articles, add the following highlighted code
echo html_input('checkbox', 'publish_article', 'pu', 'YES', l('publish_article'), '', '', '', '', $frm_publish, '', '', '', '', '');
if ($contents == 'page_new' || $edit_option == '3') {
echo html_input('checkbox', 'show_in_nav', 'shownav', 'YES', l('show_in_nav'), '', '', '', '', $frm_show_in_nav, '', '', '', '', '');
}
inside function admin_articles, add the following highlighted code
} elseif ($contents == 'page_view') {
$sql = "SELECT id, title, seftitle, date, published, artorder, visible, default_page, show_in_nav
FROM "._PRE.'articles'."
WHERE position = 3 $subquery
ORDER BY artorder ASC, date DESC ";
now in function processing, add the following highlighted code
$show_on_home = ($_POST['show_on_home'] == 'on' || $position > 1) ? 'YES' : 'NO';
$show_in_nav = $_POST['show_in_nav'] == 'on' ? 'YES' : 'NO';
still in function processing, add the following highlighted code
case (isset($_POST['add_article'])):
mysql_query("INSERT INTO "._PRE.'articles'."(
title, seftitle, text, date, category,
position, extraid, page_extra, displaytitle,
displayinfo, commentable, published, description_meta,
keywords_meta, show_on_home, show_in_subcats, show_in_nav, artorder)
VALUES('$title', '$seftitle', '$text', '$date', '$category',
'$position', '$def_extra', '$page', '$display_title',
'$display_info', '$commentable', '$publish_article',
'$description_meta', '$keywords_meta', '$show_on_home',
'$show_in_subcats', '$show_in_nav', '$artorder')");
break;
still in function processing, add the following highlighted code
show_in_subcats='$show_in_subcats',
show_in_nav='$show_in_nav',
artorder = '$artorder'
OK, that should do it for the core php code, now open your language file (EN.php in the lang folder probably) and add the following
$l['show_in_nav'] = 'Show page in navigation menu?';
That should do it, upload your modified files and give it a whirl.
Comments
RSS Comments Feed
Steve Iott
Nice work -- and thank you.
Philippe
Welldone Matt.
Sven/Philippe
Matt
I ask because to hide a category or subcategory from the home page listings would add another layer of work needed.
Sven/Philippe
Another layer? Forget it. I'm gonna make it... manually.
John Flower
Rizal
Hay Matt, how to make a long page title become shorter in menu page ..
For example the page title is
"sNews page navigation mod"
and we want the title in the menu page is just
"Page Mod"
sorry if my english is bad, thxs before
Matt
That's an excellent idea for a mod, we could add a separate "menu title" for articles & pages.
It would probably require quite a few tweaks in existing functions, like menu_articles & breadcrumbs, but I will have a look in the coming week at doing something like that.