Best use of templates to separate dynamic data

From: Date: Wed, 07 Nov 2001 15:48:02 +0000
Subject: Best use of templates to separate dynamic data
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1848@lists.php.net to get a copy of this message
Hi, I am writing an image gallery at the moment, and need to create next/previous buttons as/if required. In PHP code, I came up with the following: // $page is the page to display - passed via GET // MAX_THUMBNAILS is the max number to display per page // $num_rows is the number of rows returned from the database // Normal results: 1 2 3 4 // To add: next/prev links if ($num_rows > MAX_THUMBNAILS){
        $num_pages = ceil($num_rows / MAX_THUMBNAILS);
        for ($i = 0; $i < $num_pages; $i++) {
                $page_num = $i + 1;
                if (isset($page) && $page == $page_num){
                        $next_prev .= "<strong>$page_num</strong> ";
                } else {
                        $next_prev .= "<a href=\"show_cat.php?page=$page_num\">$page_num</a> ";
                }
        } // end for
} else {
        $next_prev = "Page 1 of 1";
} I can see no easy way of making this template based, but I would really like to separate all presentation from my code. Has anyone got any suggestions? Or is this one of those examples where the aim of separating presentation and code doesn't stand up to real world use? Thanks, Peter. ---oOo--- sendcard - *The* PHP e-card solution http://www.sendcard.f2s.com/ ---oOo---

« previous php.smarty.general (#1848) next »