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? |
|
|
|
![]() |
Post
#2
|
|
|
Grupa: Zarejestrowani Postów: 91 Pomógł: 4 Dołączył: 14.10.2012 Ostrzeżenie: (0%)
|
robię
{pagination_render} Kod function paginacja(){ 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 $pagination->render(); } $smarty->assign("paginacja",paginacja()); to jest w pliku ban_list.php Kod {$paginacja} {paginacja} Niestety, nie działa. Ten post edytował ratosluaf 29.10.2012, 15:40:28 |
|
|
|
ratosluaf Jak używać php w smarty. 29.10.2012, 15:14:29
nospor CytatWrzucenie kodu paginacji do funkcji i wywoływ... 29.10.2012, 15:16:49
nospor Przecież wyraźnie napisałem {$pagination_rend... 29.10.2012, 15:33:23
ratosluaf I to i to nie działa, patrz post wyżej. 29.10.2012, 15:36:14
nospor 1) Z kodu wynika, że o to:
$smarty->assign... 29.10.2012, 15:38:59
ratosluaf Napisałem tak, bo nie chciałem podawać całego amx_... 29.10.2012, 15:42:05
nospor No ale funkcja render() też musi zwracać kod. Jeśl... 29.10.2012, 15:44:10
ratosluaf Okej, ale jeżeli w amx_bans.php nie użyję funkcji ... 29.10.2012, 15:44:15
nospor Bo pewnie twoja funkcja render() ma ECHO które plu... 29.10.2012, 15:45:47
ratosluaf Kod /**
* Generates the output.
*
* ... 29.10.2012, 15:47:50
nospor No render() ma mieć na końcu:
return $output;... 29.10.2012, 15:48:51
ratosluaf Kod$output = return $pagination->ren... 29.10.2012, 15:52:39
nospor return $output;
To ma być na końcu funkcji re... 29.10.2012, 15:54:05
ratosluaf Jest już takie coś:
Kodecho $output; 29.10.2012, 15:55:38
nospor Przecież napisałem wyraźnie:
return $output;
... 29.10.2012, 16:00:22
ratosluaf Dzięki, w końcu działa
Jeszcze nigdy nie spotkałe... 29.10.2012, 16:14:20 ![]() ![]() |
|
Aktualny czas: 27.12.2025 - 23:13 |