1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Seperating sort filters

Discussion in 'General Troubleshooting' started by baadier, Feb 5, 2010.

  1. baadier

    baadier Well-Known Member

    guys im struggling to seperate the sort filters, id like to have my upcoming, top and all in a seperate spot from the best from today and the last 24 hours. Just moving the list didnt work out and i could probably enter the link items like this http://www.mysite.com/index.php?page=latest as just a plain unordered list but im pretty sure theirs a cleaner way to do it
     
  2. Nick

    Nick Well-Known Member

    This will require some creative thinking! We know that the theme_index_pre_main function in SB Base generates the links, and we can't divide that function without extending the plugin, but we can use the output it generates in more than one place.

    As a demonstration, in your index.php template, change this:

    PHP:
    <!-- FILTER TABS -->
    <?php 
         
    // plugin hook
         
    $result $h->pluginHook('theme_index_pre_main');
    ?>
    PHP:
    <!-- FILTER TABS -->
    <?php 
         
    // plugin hook
         
    $result $h->pluginHook('theme_index_pre_main');
         
    $h->displayTemplate('test');
    ?>
    In your theme folder, you will need two copies of the sb_sort_filter.php template from the SB Base plugin. Rename one of them as test.php.

    When that's done, Hotaru will run the pluginHook and output the usual template containing all the sort and filter links. Then, immediately after, it will display your test.php template so you have two sets of links. Now all you need to do is edit the templates to keep or strip out stuff.

    Edit: You can put the second template anywhere, just as long as it comes after the plugin hook where the links are generated.
     
    baadier likes this.
  3. baadier

    baadier Well-Known Member

    hmm..it works but i id like to include the second file in the header php, is there something im missing because just calling the same file in header.php gives me the same problem. your method does work though by the way and thanks alot for the ongoing support.
     
  4. Nick

    Nick Well-Known Member

    Put this in the header:

    PHP:
    $h->pluginHook('theme_index_pre_main''sb_base');
    That will run only the sb_base function for that plugin hook and generate all the links you need. Then, change the sb_sort_filter.php template so it only shows the links you want.

    Next, change the plugin hook in the body to this:

    PHP:
    <!-- FILTER TABS -->
    <?php 
        
    // plugin hook
        
    $result $h->pluginHook('theme_index_pre_main''', array(), array('sb_base');
    ?>
    That will allow other plugins to use the hook as normal, but exclude the sb_base plugin which you used in the header.

    Finally, put this anywhere you want:

    PHP:
    $h->displayTemplate('test');
    ... and edit the test.php template to remove the links you don't want.
     
  5. baadier

    baadier Well-Known Member

    does that go in the header.php or in the html header?

    ive assumed you change that in the index.php file and replace
     
  6. Nick

    Nick Well-Known Member

    1. header.php template
    2. Yes

    :)
     
  7. baadier

    baadier Well-Known Member

    still not working im getting a "blank screen of death"?

    ive changed the filter tabs section to the array-ed version in my index.php then ive added this into my header.php file

    Code:
     <!-- CATEGORIES, ETC -->
    		<div id="categories_kisp"><?php $h->pluginHook('header_end'); ?></div>	 <br /><br />
    
          <?php $h->displayTemplate('top'); ?>
    </div> <!-- Fine div header --> 
    </div> <!-- Fine div header-wrap -->
    
    i named my modified sb_sort file "top" btw and id the like sort list to display at the end of my header as you can see.
    ive then added this on line 42 of my header.php

    Code:
               $h->pluginHook('theme_index_pre_main', 'sb_base');  
    
    
    that particular hook just doesnt look write and it doesnt work either hmm
     
  8. Nick

    Nick Well-Known Member

    The blank screen of death is probably because you have DEBUG mode off. Turn it on in Admin -> Settings so you can see if you're getting any errors.

    I followed my own instructions above and it worked for me. I put the hook above my categories bar, and displayed the top.php template below the category bar:

    split_sort_example.png

    So I'm not sure what you're doing differently. Maybe you need to wrap PHP tags around the hook?

    PHP:
    <?php $h->pluginHook('theme_index_pre_main''sb_base'); ?>
     
  9. baadier

    baadier Well-Known Member

    im still not having any luck on this, hoping someone can have a look at it to see where im going wrong

    header.php
    PHP:
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php echo $h->getTitle(); ?></title>
        
            <?php
                
    // plugin hook
                
    $result $h->pluginHook('header_meta');
                if (!
    $result) { ?>
                    <meta name="description" content="<?php echo $h->lang['header_meta_description']; ?>" />
                    <meta name="keywords" content="<?php echo $h->lang['header_meta_keywords']; ?>" />
            <?php ?>
       
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js?ver=1.4.0'></script>
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js?ver=1.7.2'></script>
        <script type="text/javascript" src="<?php echo BASEURL 'javascript/hotaru.js'?>"></script>

        <!-- Include merged files for all the plugin css and javascript (if any) -->
        <?php $h->doIncludes(); ?>
        <!-- End -->
           
        <link rel="stylesheet" href="<?php echo BASEURL 'content/themes/' THEME 'css/screen.css'?>" type="text/css" />
    <link rel="shortcut icon" href="<?php echo BASEURL?>favicon.ico" /> 
       
        <?php $h->pluginHook('header_include_raw'); ?>

    </head>
    <body>
    <div id="header-wrap">
    <div id="header" class="container_16">

    <?php $h->pluginHook('post_open_body'); ?>

    <?php if ($announcements $h->checkAnnouncements()) { ?>
        <div id="announcement">
            <?php $h->pluginHook('announcement_first'); ?>
            <?php foreach ($announcements as $announcement) { echo $announcement "<br />"; } ?>
            <?php $h->pluginHook('announcement_last'); ?>
        </div>
    <?php ?>


            <!-- NAVIGATION -->
            <?php echo $h->displayTemplate('navigation'); ?>
    <?php $h
    ->pluginHook('theme_index_pre_main''sb_base'); ?> 
            <!-- TITLE & AD BLOCKS -->
            <div id="logo" ><a href="<?php echo BASEURL?>"><img src="<?php echo BASEURL?>content/themes/<?php echo THEME?>images/logo.png" id="noborder" title="<?php echo SITE_NAME?>"></a>&nbsp;&nbsp;
    <script type="text/javascript"><!--
    google_ad_client = "pub-9341027581385517";
    /* 468x60, created 2/3/10 */
    google_ad_slot = "1983166867";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div>
        
                

            <!-- CATEGORIES, ETC -->
            <div id="categories_kisp"><?php $h->displayTemplate('top'); ?><?php $h->pluginHook('header_end'); ?></div>     <br /><br />
        
          
    </div> <!-- Fine div header --> 
    </div> <!-- Fine div header-wrap -->
    and index.php
    PHP:
    // plugin hook
    $result = $h->pluginHook('theme_index_top');
    if (!$result) {
    ?>
            <!-- HEADER-->

            <?php
                
    // plugin hook
               
                
    $result $h->pluginHook('theme_index_header');
                if (!
    $result) {
                    
    $h->displayTemplate('header');
                }
            
    ?>
    <!-- div content starts -->
    <div id="content-outer">
    <div id="content-wrapper" class="container_16">
        <!-- BREADCRUMBS -->
            <div id='breadcrumbs'>
            <?php echo $h->breadcrumbs(); ?>
            </div>
            
                                <!-- USER TABS -->
                                <?php 
                                    
    // plugin hook
                                    
    $result $h->pluginHook('theme_index_post_breadcrumbs');
                                
    ?>
                                
                                <!-- FILTER TABS -->
                                <?php 
                                    
    // plugin hook
                            
    $result $h->pluginHook('theme_index_pre_main''', array(), array('sb_base');
                              
                                
    ?>
                                
                                <!-- MAIN -->
                                
    <?php if ($h->pageName == "submit1" || $h->pageName == "submit2" || $h->pageName == "edit_post") {  "<div id=\"submission\">"; }
    else {
    echo 
    "<div id=\"main\" class=\"grid_11\">"
    ?>
                                <?php     
                                    
    // plugin hook
                                
    $result $h->pluginHook('theme_index_main');
                                if (!
    $result) {
                                    
    $h->displayTemplate($h->pageName); 
                                }
                            
    ?>    
            </div>

                        <?php if ($h->sidebars) { ?>

    <?php if ($h->pageName == "submit1" || $h->pageName == "submit2" || $h->pageName == "edit_post")
    // DO NOTHING Submission in progress 
        
    echo "<style type=\"text/css\">
        <!-- #main form {
        width: 870px;
        }
        --></style>"
    ;
    }
    else {
                          echo 
    "<!-- SIDEBAR -->
                                <!-- left-columns starts -->
                                <div id=\"left-columns\" class=\"grid_5\" style=\"margin-top: -65px;\">
                                <div class=\"grid_5 alpha\"><!-- left-sidebar starts -->
                                <div class=\"sidemenu\">"
    ;    
                                
                            
                                    
    // plugin hook
                                    
    $result $h->pluginHook('theme_index_sidebar');
                                    if (!
    $result) {
                                    
                                        
    $h->displayTemplate('sidebar_right');
                                    }                                
                                
                         echo 
    "</div>
                                </div>
                                <div class=\"grid_5 omega\"><!-- right-sidebar starts -->
                                <div class=\"sidemenu\">"
    ;
                                
                                    
    // plugin hook
                                   
    $result $h->pluginHook('theme_index_sidebar_2');
                                    if (!
    $result) {
                                        
    $h->displayTemplate('sidebar_left');
                                    }                                
                                
                          echo 
    "</div>
                                </div>
                                </div>"
    ;
                                } 
    ?>

                        <?php ?>

            <!-- FOOTER -->
            <?php
                
    // plugin hook
                
    $result $h->pluginHook('theme_index_footer');
                if (!
    $result) {
                    
    $h->displayTemplate('footer');
                }
            
    ?>
    <?php    
    ?>
     
  10. Nick

    Nick Well-Known Member

    You're missing a ) at the end of:

    PHP:
                                <!-- FILTER TABS -->
                                <?php 
                                    
    // plugin hook
                            
    $result $h->pluginHook('theme_index_pre_main''', array(), array('sb_base');
    Make sure you've got DEBUG mode on or you won't see any errors.

    If that doesn't fix your problem, let us know what output you're getting.
     
  11. baadier

    baadier Well-Known Member

    ok the missing ) fixed that problem, i cant believe i didnt see it earlier. ive got one of my 2 seperate filters displaying. ive seperated the upcoming and all options and i have the direct time releated filters seperate??

    in other words, only 1 of my sort lists is displaying, do i have to call the other directly

    PHP:
    $h->displayTemplate('sb_sort_filter');  
     
    Last edited: Feb 8, 2010
  12. Nick

    Nick Well-Known Member

    The first plugin hook runs the function that generates the links and displays sb_sort_filter.php, so you don't have to call that one directly. The only template you need to explicitly display is your "top" one. So, which template is working, and which isn't?

    Edit:

    Just to be sure, you do have sb_sort_filter.php and top.php in your theme folder, right? I can't see anything in the code you pasted before that would prevent those from showing unless there's a problem in the templates themselves. Feel free to paste the code from those template files if you're still stuck.
     
  13. baadier

    baadier Well-Known Member

    ive got both files uploaded, and the file that doesnt display is the one referenced in my index.php, this is what my header.php looks like

    PHP:
    <?php
    /**
     * Theme name: Keep it Simple
     * Template name: header.php
     * Original Template author: Nick Ramsay
     * Original Design: Erwin Aligam
     * Original Author URI : http://www.styleshout.com/ 
     * Template author: Carlo Armanni
     *
     * PHP version 5
     *
     * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 
     * modify it under the terms of the GNU General Public License as 
     * published by the Free Software Foundation, either version 3 of 
     * the License, or (at your option) any later version. 
     *
     * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
     * FITNESS FOR A PARTICULAR PURPOSE. 
     *
     * You should have received a copy of the GNU General Public License along 
     * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
     * 
     * @category  Content Management System
     * @package   HotaruCMS
     * @author    Carlo Armanni <admin@tr3ndy.com>
     * @copyright Copyright (c) 2009, Hotaru CMS
     * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
     * @link      http://www.tr3ndy.com/
     */

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php echo $h->getTitle(); ?></title>
              

            <?php
                
    // plugin hook
                
    $result $h->pluginHook('header_meta');
                if (!
    $result) { ?>
                    <meta name="description" content="<?php echo $h->lang['header_meta_description']; ?>" />
                    <meta name="keywords" content="<?php echo $h->lang['header_meta_keywords']; ?>" />
            <?php ?>
       
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js?ver=1.4.0'></script>
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js?ver=1.7.2'></script>
        <script type="text/javascript" src="<?php echo BASEURL 'javascript/hotaru.js'?>"></script>

        <!-- Include merged files for all the plugin css and javascript (if any) -->
        <?php $h->doIncludes(); ?>
        <!-- End -->
           
        <link rel="stylesheet" href="<?php echo BASEURL 'content/themes/' THEME 'css/screen.css'?>" type="text/css" />
    <link rel="shortcut icon" href="<?php echo BASEURL?>favicon.ico" /> 
       
        <?php $h->pluginHook('header_include_raw'); ?>

    </head>
    <body>
    <?php  $h->pluginHook('theme_index_pre_main''sb_base');  ?>
    <div id="header-wrap">
    <div id="header" class="container_16">
    <?php $h->pluginHook('post_open_body'); ?>

    <?php if ($announcements $h->checkAnnouncements()) { ?>
        <div id="announcement">
            <?php $h->pluginHook('announcement_first'); ?>
            <?php foreach ($announcements as $announcement) { echo $announcement "<br />"; } ?>
            <?php $h->pluginHook('announcement_last'); ?>
        </div>
    <?php ?>


            <!-- NAVIGATION -->
            <?php echo $h->displayTemplate('navigation'); ?>
            <!-- TITLE & AD BLOCKS -->
            <div id="logo" ><a href="<?php echo BASEURL?>"><img src="<?php echo BASEURL?>content/themes/<?php echo THEME?>images/logo.png" id="noborder" title="<?php echo SITE_NAME?>"></a>&nbsp;&nbsp;
    <script type="text/javascript"><!--
    google_ad_client = "pub-9341027581385517";
    /* 468x60, created 2/3/10 */
    google_ad_slot = "1983166867";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div>
        
                

            <!-- CATEGORIES, ETC -->
            <div id="categories_kisp">    <?php $h->pluginHook('header_end'); ?>    </div> <br /><br />
    <?php $h->displayTemplate('top');  ?>
          
    </div> <!-- Fine div header --> 
    </div> <!-- Fine div header-wrap -->
    my index file only has the array changed in filters ive got debug on and i get no errors either. i have noticed when trying to refresh that it appears to load it but then it disappears as well as my theme looks slightly off with a margin appearing at the top
     
  14. Nick

    Nick Well-Known Member

    Both templates are being called from your header.php file:
    PHP:
    <?php  $h->pluginHook('theme_index_pre_main''sb_base');  ?>
    displays sb_sort_filter.php, and

    PHP:
    <?php $h->displayTemplate('top');  ?>
    displays top.php

    The line in your index.php file has been edited to prevent sb_sort_filter.php being displayed a second time. I notice you're displaying sb_sort_filter.php right at the very, very top, immediately after the opening body tag. Is that what you want?

    My gut feeling is the code you are pasting here in this thread works fine, and the problem lies in how you've edited sb_sort_filter.php and top.php.

    EDIT: Yes! Check your source code. You can see the filter is being displayed immediately after the BODY tag.
     
  15. baadier

    baadier Well-Known Member

    hmm..

    these are my 2 filter files

    top.php
    PHP:
    ?>

    <!-- SORT -->
    <div id="sort_box">
        <ul class="sort_menu">
        
            <li <?php echo $h->vars['popular_active']; ?>>
                <a href="<?php echo $h->vars['popular_link']; ?>">
                <?php echo $h->lang["sb_base_sort_recently_popular"]; ?></a>
            </li>

            <li <?php echo $h->vars['upcoming_active']; ?>>
                <a href="<?php echo $h->vars['upcoming_link']; ?>">
                <?php echo $h->lang["sb_base_sort_upcoming"]; ?></a>
            </li>
            
            <li <?php echo $h->vars['latest_active']; ?>>
                <a href="<?php echo $h->vars['latest_link']; ?>">
                <?php echo $h->lang["sb_base_sort_latest"]; ?></a>
            </li>
            
            <li <?php echo $h->vars['all_active']; ?>>
                <a href="<?php echo $h->vars['all_link']; ?>">
                <?php echo $h->lang["sb_base_sort_all"]; ?></a>
            </li>
           <br />      
        </ul>
    </div>
    and sb_sort_filter.php
    PHP:
    ?>

    <!-- SORT -->
    <div id="sort_box">
        <ul class="sort_menu">
        

            <li>
            <?php echo $h->lang["sb_base_sort_best_from"]; ?></li>
            
            <li <?php echo $h->vars['top_24_hours_active']; ?>>
                <a href="<?php echo $h->vars['24_hours_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_1_day"]; ?></a>
            </li>
            
     
            <li <?php echo $h->vars['top_48_hours_active']; ?>>
                <a href="<?php echo $h->vars['48_hours_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_2_days"]; ?></a>
            </li>

            
            <li <?php echo $h->vars['top_7_days_active']; ?>>
                <a href="<?php echo $h->vars['7_days_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_7_days"]; ?></a>
            </li>
            
            <li <?php echo $h->vars['top_30_days_active']; ?>>
                <a href="<?php echo $h->vars['30_days_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_30_days"]; ?></a>
            </li>
            
            <li <?php echo $h->vars['top_365_days_active']; ?>>
                <a href="<?php echo $h->vars['365_days_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_365_days"]; ?></a>
            </li>
            
            <li <?php echo $h->vars['top_all_time_active']; ?>>
                <a href="<?php echo $h->vars['all_time_link']; ?>">
                <?php echo $h->lang["sb_base_sort_top_all_time"]; ?></a>
            </li>
            
        </ul>
    </div>
    what i think you're saying is that the line
    PHP:
     <?php  $h->pluginHook('theme_index_pre_main''sb_base');  ?>
    displays the original sort list? where would you put it then to display the list in the "default" position as per the demo?
     
  16. baadier

    baadier Well-Known Member

    ive called

    PHP:
    <?php  $h->pluginHook('theme_index_pre_main''sb_base');  ?>
    in my footer.php and it displays the bar but i get some errors with the other list that used to display. does that hook have to be called before i try to include the second one?
     
  17. baadier

    baadier Well-Known Member

    and ive got it working, ive swapped the content from the 2 sort files so the sort list i want to display first is called with this
    PHP:
    <?php  $h->pluginHook('theme_index_pre_main''sb_base');  ?> 
    and the second list i wanted to call is in my top.php file.

    thanks alot nick, much appreciated and my apologies for taking 16 posts to figure it out!
     
  18. Nick

    Nick Well-Known Member

    Glad you got it working! :)
     
  19. baadier

    baadier Well-Known Member

    Thanks man, you should have a look at the site its starting to take shape nicely now
     

Share This Page