sNews page navigation mod, a mod to hide pages from the navigation menu
filed under: sNews CMS / Hacks & Mods
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.
5 comments
Add a new comment »Categories
Recent Entries
Recent Comments
- Dede (I checked it today in a shop. GT2 had some troubles with six ...)
- Matt (Bintang, You need to re-direct the url, try ...)
- jesth (Ohh.. why didn't I think of that, thanks alot.)
- Matt (Dede, I don't have Gran Turismo 2, any of the 2nd+ generation ...)
- Matt (Jesth, Just change the if condition, instead of looking for ...)
- jesth (Hi (again) Was wondering, is it possible to make it ...)
- Bintang Sembilan (Matt, thanks for your modd. I have apply it to my ...)
- Dede (Hello there. Can you check something for me? I want to buy ...)
- Matt (I think it's a driver issue Terrence, or it was a driver issue. ...)
Popular Entries
- Light-weight related articles mod for sNews 1.7 (4.5/5)
- Image / math hybrid captcha version 2, vastly improved (4.42/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.4/5)
- Compact archives for sNews 1.7 (4.4/5)
- sNews Ajax Polls mod now available (4.38/5)
- Pretty date and comments bars in sNews CMS (4.35/5)
- Page caching mod for sNews 1.7 (4.33/5)
- Gravatar mod for sNews 1.7 (4.29/5)
- An improved tag cloud for sNews 1.7 (4.29/5)
Feb 10th, 2009 at 3:50 pm
Pure Gold!
Nice work -- and thank you.
Feb 14th, 2009 at 1:58 am
Gee! So good!
Welldone Matt.
Apr 7th, 2010 at 6:28 am
Hey Matt. You know what? Same for categories and subcategories would be great. What da ya think of this idea?
Apr 7th, 2010 at 11:33 am
Sven, you mean to hide the category or subcategory from the categories menu, correct?
I ask because to hide a category or subcategory from the home page listings would add another layer of work needed.
Apr 7th, 2010 at 12:21 pm
Yeap that's right Sir.
Another layer? Forget it. I'm gonna make it... manually.