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
$output = return $pagination->render(true);

Tak to ma wyglądać? (Pytanie jest głupie i pyta o banały, ale gdybym nie raczkował w php, to bym o takie rzeczy się nie pytał, a dokumentacja mówi mało o używaniu funkcji w zmiennych)

Cały kod:
Kod
require_once("include/db.config.inc.php");
// how many records should be displayed on a page?
$records_per_page = 50;

// include the pagination class
require 'Zebra_Pagination.php';

// instantiate the pagination object
$pagination = new Zebra_Pagination();

// the MySQL statement to fetch the rows
// note how we build the LIMIT
// also, note the "SQL_CALC_FOUND_ROWS"
// this is to get the number of rows that would've been returned if there was no LIMIT
// see http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
$mysql = mysql_connect($config->db_host,$config->db_user,$config->db_pass);
$MySQL = 'SELECT SQL_CALC_FOUND_ROWS bid FROM amx_bans LIMIT ' . (($pagination->get_page() - 1) * $records_per_page) . ', ' . $records_per_page . '';

// if query could not be executed
if (!($result = @mysql_query($MySQL))) {

    // stop execution and display error message
    die(mysql_error());
    }
// pass the total number of records to the pagination class
$pagination->records($rows['rows']);

// records per page
$pagination->records_per_page($records_per_page);

// render the pagination links
$output = echo $pagination->render(true);

$smarty->assign("output",$output);


Nie wyświetla się nic...

Ten post edytował ratosluaf 29.10.2012, 15:54:26
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: 27.12.2025 - 23:44