sNews page navigation mod, a mod to hide pages from the navigation menu

Comments (5)

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.

page hide checkbox preview

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.

bookmark / share this: Bookmark and Share
rated 3.63/5 (8 votes)


5 comments

Add a new comment »

Steve Iott Steve Iott said:
Feb 10th, 2009 at 3:50 pm

Pure Gold!

Nice work -- and thank you.


Philippe Philippe said:
Feb 14th, 2009 at 1:58 am

Gee! So good!
Welldone Matt.


Sven/Philippe Sven/Philippe said:
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?


Matt Matt said:
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.


Sven/Philippe Sven/Philippe said:
Apr 7th, 2010 at 12:21 pm

Yeap that's right Sir.
Another layer? Forget it. I'm gonna make it... manually.



Write a comment

* = required field

:

:

:

:

You may insert urls in plain text, urls will be automatically linkified for trusted users and on seasoned posts only. All first comments are moderated, so use your email if you want to be remembered.


Back to top