Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak używać php w smarty.
ratosluaf
post
Post #1





Grupa: Zarejestrowani
Postów: 91
Pomógł: 4
Dołączył: 14.10.2012

Ostrzeżenie: (0%)
-----


Jak mogę użyć PHP w szablonie smarty? Użycie tagów {php} nie przynosi skutków.
Posiadam taki kod:
Kod
$pagination->render();

Odpowiada on za wyświetlanie się paginacji.
Kod
$smarty->assign("pagination_render",$pagination->render());

Nie działa.
Wrzucenie kodu paginacji do funkcji i wywoływanie funkcji przez assign też nie działa.

Jak więc dodać tam ten kod?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ratosluaf
post
Post #2





Grupa: Zarejestrowani
Postów: 91
Pomógł: 4
Dołączył: 14.10.2012

Ostrzeżenie: (0%)
-----


Kod
   /**
     *  Generates the output.
     *
     *  <i>Make sure your script references the CSS file!</i>
     *
     *  <code>
     *  //  generate output but don't echo it
     *  //  but return it instead
     *  $output = $pagination->render(true);
     *  </code>
     *
     *  @param  boolean     $return_output      Setting this argument to TRUE will instruct the script to return the
     *                                          generated output rather than outputting it to the screen.
     *
     *                                          Default is FALSE.
     *
     *  @return void
     */
    function render($return_output = false)
    {

        // get some properties of the class
        $this->get_page();

        // if there is a single page, or no pages at all, don't display anything
        if ($this->_total_pages <= 1) return '';

        // start building output
        $output = '<div class="pagination">';

        // if the number of total pages available is greater than the number of selectable pages
        // it means we can show the "previous page" link
        if ($this->_total_pages > $this->_selectable_pages) {

            $output .= '<a href="' .

                // the href is different if we're on the first page
                ($this->page == 1 ? 'java script:void(0)' : $this->_build_uri($this->page - 1)) .

                // if we're on the first page, the link is disabled
                '" class="navigation left' . ($this->page == 1 ? ' disabled' : '') . '"' .

                // good for SEO
                // http://googlewebmastercentral.blogspot.de/2011/09/pagination-with-relnext-and-relprev.html
                ' rel="prev"' .

                '>previous page</a>';

        }


Dokładnie, czyli wystarczy użyć tej zmiennej i potem przypisać ją do templatki?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.12.2025 - 04:41