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: [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages  (Read 6019 times)

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
[MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
« on: June 19, 2007, 07:27:32 pm »

MOD name: [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
sNews version: v1.6

Information:
With this Mod you can "hide" the Home, Contact, Archive or Site Map in any combination that you want.
Functions affected: Pages()

Backup your snews.php and your DataBase too.

Go!

Step #1:
Create four new rows into your current database. Execute this under your phpmyadmin like DB panel:
Quote
INSERT INTO settings (id, name, value) VALUES
('','disable_home',''),
('','disable_archive',''),
('','disable_contact',''),
('','disable_sitemap','');
Step #2:
Add these language variables:
Quote
//START [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
$l['t_disable_home'] = 'Hide Home from Pages?';
$l['t_disable_archive'] = 'Hide Archive from Pages?';
$l['t_disable_contact'] = 'Hide Contact from Pages?';
$l['t_disable_sitemap'] = 'Hide Site Map from Pages?';
//END [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
Step #3:
Locate the function Pages() and replace it with this one:
Quote
//START [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
function pages() {
   $categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
   $class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
   if (s('disable_home') != 'on') {
   echo '
  • '.l('home').'
  • ';
       $class = ($categorySEF == 'archive') ? ' class="current"' : '';
       }
       if (s('disable_archive') != 'on') {
       echo '
  • '.l('archive').'
  • ';
       }
       $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";
       $result = mysql_query($query);
       while ($r = mysql_fetch_array($result)) {
          $title = $r['title'];
          $class = ($pageSEF == $r['seftitle'])? ' class="current"' : '';
          if ($r['id'] != s('display_page')) {echo '
  • '.$title.'
  • ';}
       }
       if (s('disable_contact') != 'on') {
       $class = ($categorySEF == 'contact') ? ' class="current"': '';
       echo '
  • '.l('contact').'
  • ';
       }
       if (s('disable_sitemap') != 'on') {
       $class = ($categorySEF == 'sitemap') ? ' class="current"': '';
       echo '
  • '.l('sitemap').'
  • ';
       }
    }
    //END [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
    Step #4:
    Next, under function settings, locate this line:
    Quote
    echo html_input('checkbox', 'num_categories', 'nc', '', l('a_num_categories'), '', '', '', '', (s('num_categories') == 'on' ? 'ok' : ''), '', '', '', '', '');
    And, next to it, add this:
    Quote
    //START [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
       echo html_input('checkbox', 'disable_home', 'hh', '', l('t_disable_home'), '', '', '', '', (s('disable_home') == 'on' ? 'ok' : ''), '', '', '', '', '');
       echo html_input('checkbox', 'disable_archive', 'ha', '', l('t_disable_archive'), '', '', '', '', (s('disable_archive') == 'on' ? 'ok' : ''), '', '', '', '', '');
       echo html_input('checkbox', 'disable_contact', 'hc', '', l('t_disable_contact'), '', '', '', '', (s('disable_contact') == 'on' ? 'ok' : ''), '', '', '', '', '');
       echo html_input('checkbox', 'disable_sitemap', 'hs', '', l('t_disable_sitemap'), '', '', '', '', (s('disable_sitemap') == 'on' ? 'ok' : ''), '', '', '', '', '');
    //END [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
    Step #5:
    Now, locate under function processing() this line:
    Quote
    $num_categories = $_POST['num_categories'];
    And, next to it, add:
    Quote
    //START [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
    $disable_home = $_POST['disable_home'];
    $disable_archive = $_POST['disable_archive'];
    $disable_contact = $_POST['disable_contact'];
    $disable_sitemap = $_POST['disable_sitemap'];
    //END [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
    Few lines down, locate the line:
    Quote
    $ufield = array('website_title' => $website_title,'home_sef' => $home_sef,'website_description' => $website_description,'website_keywords' => $website_keywords,'website_email' => $website_email,'contact_subject' => $contact_subject,'language' => $language,'charset' => $charset,'date_format' => $date_format,'article_limit' => $article_limit,'rss_limit' => $rss_limit,'display_page' => $display_page,'comments_order' => $comments_order,'comment_limit' => $comment_limit,'word_filter_file' => $word_filter_file,'word_filter_change' => $word_filter_change,'display_new_on_home' => $display_new_on_home,'display_pagination' => $display_pagination,'num_categories' => $num_categories,'approve_comments' => $approve_comments,'word_filter_enable' => $word_filter_enable,);
    And change it to:
    Quote
    $ufield = array('website_title' => $website_title,'home_sef' => $home_sef,'website_description' => $website_description,'website_keywords' => $website_keywords,'website_email' => $website_email,'contact_subject' => $contact_subject,'language' => $language,'charset' => $charset,'date_format' => $date_format,'article_limit' => $article_limit,'rss_limit' => $rss_limit,'display_page' => $display_page,'comments_order' => $comments_order,'comment_limit' => $comment_limit,'word_filter_file' => $word_filter_file,'word_filter_change' => $word_filter_change,'display_new_on_home' => $display_new_on_home,'display_pagination' => $display_pagination,'num_categories' => $num_categories,'approve_comments' => $approve_comments,'word_filter_enable' => $word_filter_enable,'disable_home' => $disable_home,'disable_archive' => $disable_archive,'disable_contact' => $disable_contact,'disable_sitemap' => $disable_sitemap,);
    And this is all... If you want to try it, visit my demo site here.
    Enter into the site settings panel and under 'contents' you can see these options.

    Thanks,
    bram.
    Logged
    La comunidad sNews en tu idioma!
    Comunidad sNews en Espaņol

    Keyrocks

    • Doug
    • ULTIMATE member
    • ******
    • Karma: 449
    • Posts: 6020
    • Semantically Challenged
      • snews.ca
    [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
    « Reply #1 on: June 19, 2007, 11:21:54 pm »

    Well done there Brams... that didn't take too long at all. I'll have to try this out tomorrow. :)
    Logged
    Do it now... later may not come.
    -------------------------------------------------------------------------------------------------
    sNews 1.6 MESU | sNews 1.6 MEMU

    piXelatedEmpire

    • MIA
    • ULTIMATE member
    • ******
    • Karma: 37
    • Posts: 1401
    • currently MIA
    [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
    « Reply #2 on: June 21, 2007, 02:22:29 pm »

    Bram, this MOD doesn't seem to function correctly with sNews 1.6.01DE.  Everything shows up as it should however the settings are not saved when you click the 'Save' button.  I think the problem is when you click the 'Save' button in 1.6.01DE, after the 'Operation Completed Successfully' message appears you are automatically redirected to /administration/.  In sNews 1.6 however, instead of the redirection you must click the 'Back' button.  And it is after you click the 'Back' button that the Pages you selected to hide are hidden.
    Logged
    my apologies to the sNews crew, but I will be MIA for the forseeable future

    piXelatedEmpire

    • MIA
    • ULTIMATE member
    • ******
    • Karma: 37
    • Posts: 1401
    • currently MIA
    [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
    « Reply #3 on: June 21, 2007, 02:36:37 pm »

    Well well well, it would appear I managed to solve my problem!
    if your using sNews1.6.01DE there is an additional step that is required ;)
    Follow Steps 1-5 or brams first post.

    Step 6
    In function processing() find:
    Quote
    mysql_query($query_begin."'$word_filter_enable' WHERE name = 'word_filter_enable' LIMIT 1;");
    and below it add the following:
    Quote
    mysql_query($query_begin."'$disable_home' WHERE name = 'disable_home' LIMIT 1;");
    mysql_query($query_begin."'$disable_archive' WHERE name = 'disable_archive' LIMIT 1;");
    mysql_query($query_begin."'$disable_contact' WHERE name = 'disable_contact' LIMIT 1;");
    mysql_query($query_begin."'$disable_sitemap' WHERE name = 'disable_sitemap' LIMIT 1;");
    And bingo, this MOD now functions perfectly in 1.6.01DE :D
    Logged
    my apologies to the sNews crew, but I will be MIA for the forseeable future

    Keyrocks

    • Doug
    • ULTIMATE member
    • ******
    • Karma: 449
    • Posts: 6020
    • Semantically Challenged
      • snews.ca
    [MOD] Hide "Home/Contact/Archive/Sitemap" from Pages
    « Reply #4 on: June 21, 2007, 03:13:22 pm »

    @ Pix and Bram...
    This problem does not seem to happen with the normal sNews16 release... I installed it yesterday and it ran fine on the first try. I then added it to my "Enhanced Admin" package mod. :)
    Logged
    Do it now... later may not come.
    -------------------------------------------------------------------------------------------------
    sNews 1.6 MESU | sNews 1.6 MEMU

    elliotr

    • Newbie
    • *
    • Karma: 0
    • Posts: 10
    Re: [MOD] Hide \
    « Reply #5 on: October 31, 2007, 06:44:43 am »

    This mod was exactly what I was looking for however, the pages that are not set to be hidden(contact) in the admin back end are displayed as plain text and not effected by my style sheets nor are they click able links. Is this Intentional or have I entered the code incorrectly?

    Greatly Appreciated. Thanks
    Logged

    elliotr

    • Newbie
    • *
    • Karma: 0
    • Posts: 10
    Re: [MOD] Hide \
    « Reply #6 on: October 31, 2007, 07:10:23 am »

    #FIXED# It does seem odd that this was the default set up but I've fixed the problem simply by encompasing contacts(or what ever one you want) in a link tag <a> on line 43 in the language variables.

    example:
    was:
    $l['contact'] = 'Contact';

    Is:
    $l['contact'] = '<a href="/contact/">Contact</a>';
    Logged

    Keyrocks

    • Doug
    • ULTIMATE member
    • ******
    • Karma: 449
    • Posts: 6020
    • Semantically Challenged
      • snews.ca
    Re: [MOD] Hide \
    « Reply #7 on: October 31, 2007, 02:13:13 pm »

    There should be no need to add hyperlink tags to the language variable. By default, the <?php pages(); ?> function string in your index.php (template) file will display what function pages() (in snews.php) generates. If you have added all of Bramsyuur's mods as required... and you have added (INSERTED) the four default value rows in the database's settings table... it will work fine.

    By default, function pages() contains hard-coded links to the "home, archive, contact & sitemap" functions which... in turn... generate their respective pages when clicked. Following those links... the function then queries the articles table in the database to see if there are any user-created pages available and, if any exist, it then generates links to the user-created pages as well.

    The top part of function pages() (starting from under the function's first string) should look like this to make the four hard-coded page links (to the 4 sNews function-generated pages) switchable with Bramsuur's mod. As you can see, each of the links - in both their un-modded state and in the modded state (below) - already enclosed in hyperlink tags. Check to see if you replaced the default links with this:

    Quote
       $categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
       $class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
          if (s('disable_home') != 'on') {
       echo '<li> <a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a> </li>';
       $class = ($categorySEF == 'archive') ? ' class="current"' : '';
          } # closes "if"
                if (s('disable_archive') != 'on') {
       echo '<li> <a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a> </li>';
          } # closes "if"
                if (s('disable_contact') != 'on') {
       $class = ($categorySEF == 'contact') ? ' class="current"': '';
       echo '<li> <a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a> </li>';
          } # closes "if"
                if (s('disable_sitemap') != 'on') {
       $class = ($categorySEF == 'sitemap') ? ' class="current"': '';
       echo '<li> <a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a> </li>';
          } # closes "if"

    Logged
    Do it now... later may not come.
    -------------------------------------------------------------------------------------------------
    sNews 1.6 MESU | sNews 1.6 MEMU

    ens

    • Sr. Member
    • ****
    • Karma: 12
    • Posts: 279
      • http://www.meatysite.info
    Re: [MOD] Hide \
    « Reply #8 on: November 10, 2007, 11:46:58 pm »

    Okay, so what is the true, proper code to use for the regular sNews 1.6?

    I've had some trouble with bram's: the links to not show up, period.
    Logged

    Palmik

    • Jr. Member
    • **
    • Karma: 2
    • Posts: 58
      • Palmik's Page
    Re: [MOD] Hide \
    « Reply #9 on: November 26, 2007, 05:39:38 pm »

    Hello, I love this mod, but I am usind MU versin of sNews, so I modify the code a little bit.
    Function Pages:
    Code: [Select]
    // DISPLAY PAGES
    function pages() {
       $categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
       $class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
       if (s('disable_home') != 'on') {
           echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
       $class = ($categorySEF == 'archive') ? ' class="current"' : '';
       }
       if (s('disable_archive') != 'on') {
           echo '<li><a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a></li>';
       }
       $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";
       $result = mysql_query($query);
       while ($r = mysql_fetch_array($result)) {
          $title = $r['title'];
          $class = ($pageSEF == $r['seftitle'])? ' class="current"' : '';
           if ($r['id'] != s('display_page')) {echo ''.$title.'
       ';}
       }
       if (s('disable_contact') != 'on') {
       $class = ($categorySEF == 'contact') ? ' class="current"': '';
           echo '<li><a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a></li>';
       }
       if (s('disable_sitemap') != 'on') {
       $class = ($categorySEF == 'sitemap') ? ' class="current"': '';
           echo '<li><a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a></li>';
       }
    ## MULTI_USER
    if (s('registration_off') != 'on') {
    if ($_SESSION[db('website').'Logged_In'] != token()) {
    $class = ($categorySEF == 'register') ? ' class="current"': '';
    echo '<li><a'.$class.' href="'.db('website').'register/" title="'.l('register').'">'.l('register').'</a></li>';
    }
    }
    ## END MULTI_USER
    }

    Long line:
    Code: [Select]
    $ufield = array('website_title' => $website_title,'home_sef' => $home_sef,'website_description' => $website_description,'website_keywords' => $website_keywords,'website_email' => $website_email,'contact_subject' => $contact_subject,'language' => $language,'charset' => $charset,'date_format' => $date_format,'article_limit' => $article_limit,'rss_limit' => $rss_limit,'display_page' => $display_page,'comments_order' => $comments_order,'comment_limit' => $comment_limit,'word_filter_file' => $word_filter_file,'word_filter_change' => $word_filter_change,'display_new_on_home' => $display_new_on_home,'display_pagination' => $display_pagination,'num_categories' => $num_categories,'approve_comments' => $approve_comments,'word_filter_enable' => $word_filter_enable,'display_added_by' => $added_by,'comments_reg' => $comments_reg,'alert_register' => $alert_register,'alert_emailusr' => $alert_emailusr,'length_password' => $length_password,'registration_off' => $registration_off,'users_online' => $users_online, 'disable_home' => $disable_home,'disable_archive' => $disable_archive,'disable_contact' => $disable_contact,'disable_sitemap' => $disable_sitemap,);
    Logged

    Aysseline

    • Jr. Member
    • **
    • Karma: 4
    • Posts: 66
    Re: [MOD] Hide \
    « Reply #10 on: November 30, 2007, 06:53:41 pm »

    Hello bramsyuur I want to know if your MOD made different things than this Seperate Pages Function or if the result is same, thanks !
    Logged
    sNews 1.6_patched - localhost, Xampp 1.6.2 - XPSP2

    maxiso

    • Newbie
    • *
    • Karma: 0
    • Posts: 9
    Re: [MOD] Hide \
    « Reply #11 on: December 05, 2007, 05:51:56 pm »

    Works superbly.
    Logged

    bramsyuur

    • Hero Member
    • *****
    • Karma: 23
    • Posts: 873
      • http://snews.vietbee.net
    Re: [MOD] Hide \
    « Reply #12 on: December 16, 2007, 02:26:45 am »

    Hello bramsyuur I want to know if your MOD made different things than this Seperate Pages Function or if the result is same, thanks !
    Sorry for this big delay... Yes, the MOD Seperate Pages Function made differents things that mine... basically, position displaying things. In my MOD, none position are changed only was changed the visibility on or off for any item of the pages function from the admin panel.
    Thanks.
    Logged
    La comunidad sNews en tu idioma!
    Comunidad sNews en Espaņol

    anver

    • Newbie
    • *
    • Karma: 0
    • Posts: 18
    Re: [MOD] Hide \
    « Reply #13 on: May 10, 2009, 01:56:21 pm »

    Here is the Complete Code which works on snews1.6 without any problem
    Just do what the original author instructed and replace this function instead of his so the links appear correctly
    Code: [Select]
    function pages()
        {
            $categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
            $class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' : '';
            if (s('disable_home') != 'on')
            {
                echo '<li> <a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a> </li>';
                $class = ($categorySEF == 'archive') ? ' class="current"' : '';
            }
            if (s('disable_archive') != 'on')
            {
               echo '<li> <a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a>  </li>';
            }
            $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";
            $result = mysql_query($query);
            while ($r = mysql_fetch_array($result))
            {
                $title = $r['title'];
                $class = ($pageSEF == $r['seftitle'])? ' class="current"' : '';
                if ($r['id'] != s('display_page'))
                {
                    echo ''.$title.'';
                }
            }
            if (s('disable_contact') != 'on')
            {
                $class = ($categorySEF == 'contact') ? ' class="current"': '';
                echo '<li> <a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a>  </li>';
            }
            if (s('disable_sitemap') != 'on')
            {
                $class = ($categorySEF == 'sitemap') ? ' class="current"': '';
                echo '<li> <a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a> </li>';
            }
        }
        //END [MOD] Hide 'Home', 'Sitemap', 'Contact' and 'Archive' from function Pages by bramsyuur
    Logged