1

I want to know how to enable paging on my theme. The theme 'Garlik' works fine but my theme does not work why?


This is my page.tpl.php :

<?php drupal_add_css('http://fonts.googleapis.com/css?family=Josefin+Sans:regular,bold', array('type' => 'file')) ?>
<?php drupal_add_css('http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold', array('type' => 'file')) ?>
<?php drupal_add_css('http://fonts.googleapis.com/css?family=Goudy+Bookletter+1911', array('type' => 'file')) ?>
<?php drupal_add_js('jQuery(document).ready(function () { document.documentElement.className = "js"; });',
    array('type' => 'inline')
  );?>
<body class="home blog chrome">
    <div class="right-shadow">
        <div class="left-shadow">
            <div class="container clearfix">
                <div id="header" class="clearfix">
                                    <a href="<?php echo $base_path ?>">
                                        <img src="<?php echo $base_path ?><?php global $theme_path; echo  $theme_path ?>/logo.png" alt="Modest Theme" id="logo"/>
                                    </a>
                                    <ul id="top-menu" class="nav">
                                            <li id="menu-item-322" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-322">
                                                <a href="<?php echo $base_path ?>">Accueil</a>
                                            </li>
                                            <li id="menu-item-323" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-323">
                                                <a href="#" onclick="return false">Categories</a>
                                                <ul class="sub-menu">
                                                    <?php
                                                        foreach(taxonomy_get_tree(2) as $categoryObject) :
                                                            $path = taxonomy_term_uri($categoryObject);
                                                            echo '<li id="menu-item-'.$categoryObject->tid.'" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-'.$categoryObject->tid.'"><a href="'.url($path['path']).'">'.$categoryObject->name.'</a></li>';
                                                        endforeach;
                                                    ?>
                                                 </ul>
                                            </li>
                                            <li id="menu-item-372" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-372">
                                                <a href="/contact">Contact</a>
                                            </li>
                                    </ul>
                                    <div id="icons">
                                            <span>Drupal : Apprenons ensemble</span>
                                            <div id="et-social-icons">
                                                <a href='https://twitter.com/#!/drupal_addict' target='_blank'>
                                                    <img alt='Twitter' src='<?php echo $base_path.$theme_path ?>/images/twitter.png' />
                                                </a>
                                                <a href='/rss.xml' target='_blank'>
                                                        <img alt='Rss' src='<?php echo $base_path.$theme_path ?>/images/rss.png' />
                                                </a>
                                                <a href='https://www.facebook.com/pages/Drupal-Addict/222067957809636' target='_blank'>
                                                    <img alt='Facebook' src='<?php echo $base_path.$theme_path ?>/images/facebook.png' />
                                                </a>
                                            </div>
                                    </div>
                                </div> <!-- end #header -->


                <div id="content-area" class="clearfix">
                                    <div id="quote">
                                        <p id="quote-1">
                                            <span class="tagline-quote">&ldquo;</span>Drupal Addict vous permet de découvrir et <a href="#" >proposer</a> des informations sur Drupal 7<span class="tagline-quote">&rdquo;</span>
                                        </p>
                                        <p id="quote-2">En savoir plus sur Drupal 7 devient plus facile grâce à Drupal Addict</p>
                                    </div> <!-- end #quote -->
                                    <div id="blurbs" class="clearfix">

                                        <div class="blurb">
                                            <?php print render($page['content']); ?>
                                            <?php 
                                                $nodes = db_query('SELECT count(nid) as total FROM {node}');
                                                foreach($nodes as $el)
                                                {
                                                    $total = round($el->total / 10);
                                                }

                                                echo '<div id="nav">';
                                                //Si c'est la première page
                                                if(!isset($_GET['page']) && $total > 0) :
                                                    echo '<div class="left"><a href="?page=2">Articles Précédents</a></div>';
                                                endif;
                                                if(isset($_GET['page']) && $_GET['page'] == 1 && $total > 0) :
                                                    echo '<div class="left"><a href="?page=2">Articles Précédents</a></div>';
                                                endif;

                                                //Si c'est la première page
                                                if(isset($_GET['page']) && $_GET['page'] < $total + 1 && $_GET['page'] != 1) :
                                                    echo '<div class="left"><a href="'.$_GET['page']--.'">Articles Précédents</a></div>';
                                                    echo '<div class="right"><a href="?page='.$_GET['page']++.'">Articles Suivants</a></div>';
                                                endif;

                                                //Si c'est la dernière page
                                                if(isset($_GET['page']) && $_GET['page'] == $total + 1) :
                                                    $page = $_GET['page'] - 1 ;
                                                    echo '<div class="right"><a href="?page='.$page.'">Articles Suivants</a></div>';
                                                endif;
                                                echo '</div>';


                                            ?>
                                        </div>


                            <div class="blurb last">
                                                            <!--    
                    <h3 class="title">Examples of Our Work</h3>
                                                                        <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Nam libero tempore soluta" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-1.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-1.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Nam libero tempore soluta' width='56' height='56' />                                  <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                                                <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Sed neque ipsum pulvinar eu trist" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-2.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-2.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Sed neque ipsum pulvinar eu trist' width='56' height='56' />                                  <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                                                <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Cras eu eros id dui porttitor luctus" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-3.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-3.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Cras eu eros id dui porttitor luctus' width='56' height='56' />                                   <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                                                <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Vivamus vitae nibh id quam" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-4.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-4.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Vivamus vitae nibh id quam' width='56' height='56' />                                 <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                                                <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Aenean vulputate fermentum ante" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-5.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-5.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Aenean vulputate fermentum ante' width='56' height='56' />                                    <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                                                <div class="thumb">
                                <a rel="prettyPhoto[gallery]" title="Ut sagittis ultrices urna eget erat non purus" href="http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-6.png" class="prettyphoto">
                                    <img src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/Magnificent/wp-content/uploads/2009/08/thumb-6.png&amp;h=56&amp;w=56&amp;zc=1&amp;q=90" class='item-image'  alt='Ut sagittis ultrices urna eget erat non purus' width='56' height='56' />                                  <span class="overlay"></span>
                                    <span class="zoom-icon"></span>
                                </a>
                            </div>  
                                                        -->
                                                        <?php print render($page['sidebar_first']); ?>
                                        </div> <!-- end .blurb -->
                    </div> <!-- end #blurbs -->

            </div> <!-- end #content-area -->
        </div> <!-- end .container -->


            </div> <!-- end .left-shadow -->
</div> <!-- end .right-shadow -->

<div id="footer">
    <div class="right-shadow">
        <div class="left-shadow">
            <div id="footer-top">
                <div class="container">
                    <div id="footer-widgets" class="clearfix">
                        <div id="customlogowidget-4" class="footer-widget widget_customlogowidget">
<p id="footer-logo"><img alt="" style="width:90px" src="<?php echo $base_path.$theme_path ?>/logo.png" /><span>©  2011 Drupal Addict</span></p>
<div class="thumb">
    <img class="item-image"  alt="" src="http://www.elegantthemes.com/preview/Modest/wp-content/themes/Modest/timthumb.php?src=http://www.elegantthemes.com/preview/DelicateNews/wp-content/uploads/2010/07/thumb-4.png&amp;w=56&amp;h=56&amp;zc=1" />
    <span class="overlay"></span>
</div>
<p>Internautes et rédacteurs, bienvenue ! Ce site a pour objectif de rassembler nos connaissances et de les partager. Pour cela, j'ai mis en place la possibilité de créer de nouveau article. Bonne visite et participation</p>


</div> <!-- end .footer-widget -->
<div id="recent-posts-3" class="footer-widget widget_recent_entries">       
    <h4 class="widgettitle">Articles Récents</h4>
    <ul>
        <?php
            $nodes = node_get_recent(5);
            foreach ( $nodes as $node) :
                if(isset ($node->uri['path']))
                    echo '<li><a href="'.drupal_get_path_alias($node->uri['path']).'">'.$node->title.'</a></li>';
            endforeach;

         ?>
    </ul>
        </div> <!-- end .footer-widget --><div id="text-3" class="footer-widget widget_text"><h4 class="widgettitle">Mentions Légales</h4>
                <div class="textwidget">
                    <h5 style="font-size: 13px">Site Internet : Drupal Addict</h5>
                    <div>
                        Créateur / Développeur : Francis NIKOU<br/>
                        1 rue de la saussaie fleurie<br/>
                        77230 Saint Mard
                        France
                        Tel. : 06 11 75 68 70
                        mail : [email protected]
                    </div>
                    <h5 style="font-size: 13px; margin-top: 15px">Hebergement : OVH</h5>
                    <div>
                        2 rue Kellermann<br/>
                        59100 Roubaix
                        France
                        Tel. : 06 11 75 68 70
                        web : http://www.ovh.fr
                    </div>

                </div>
        </div> <!-- end .footer-widget -->                  </div> <!-- end #footer-widgets -->

                </div> <!-- end .container -->
            </div> <!-- end #footer-top -->
        </div> <!-- end .left-shadow -->
    </div> <!-- end .right-shadow -->
</div> <!-- end #footer -->
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-10074252-5']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<?php drupal_add_js($theme_path.'/js/jquery.easing.1.3.js', array('type' => 'file', 'scope' => 'footer')); ?>
<?php drupal_add_js($theme_path.'/js/superfish.js', array('type' => 'file', 'scope' => 'footer')); ?>
<?php drupal_add_js($theme_path.'/js/custom.js', array('type' => 'file', 'scope' => 'footer')); ?>
<?php drupal_add_js($theme_path.'/js/jquery.prettyPhoto.js', array('type' => 'file', 'scope' => 'footer')); ?>
<?php drupal_add_js($theme_path.'/js/et-ptemplates-frontend.js', array('type' => 'file', 'scope' => 'footer')); ?>

I don't override theme_pager. My cache is clear. This is my website : http://www.drupal-addict.fr/

4
  • Paging is a functional feature, so it is not controlled by the theme, but by the code that builds the page content. Please provide more information about the page you want to have a pager. May 17, 2011 at 23:52
  • It's just the home page. Pagination does not appear with my theme while Garlik yes.
    – Onita
    May 18, 2011 at 7:47
  • @Onita This is not a forum. If you need to update your question, you update your question; you don't create an answer, just to update your question.
    – apaderno
    May 18, 2011 at 15:19
  • Okay no problem.
    – Onita
    May 18, 2011 at 15:57

1 Answer 1

1

OK, if I understand correctly what you're trying to do...

You are not satisfied with the default Drupal pager and you're trying to build a different pager, more like the default Wordpress pager. Right?

I tried putting the large block of PHP from your code (the chunk after <?php print render($page['content']); ?>) in the original page.tpl.php of the Bartik theme and it seems to work: The output is printed right below the default pager. That said, your approach is not the right way to do it.

First of all, large blocks of php logic and database queries do not belong in template files. If you want to change what Drupal theme (like Bartik) does, you should override the appropriate theme function, in this case theme_pager. You can learn how to do that in the documentation at drupal.org. By overriding the theme function, you have all variables available (no need to run extra queries). It's the most effective way of changing the output of any element on your page.

Second, if you're running db_query('SELECT count(nid) as total FROM {node}'), that is not the same as counting all nodes on the front page. The nodes that appear on the front page are the nodes where status = 1 (it must be published) and promote = 1 (it must be promoted to the front page).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.