smarty

php-sql-smarty pagination

寵の児 提交于 2020-01-15 12:14:52
问题 I have the following code : $gemng = $db->query("SELECT * FROM students ORDER BY student_name ASC "); while($ftmng = $db->fetch_array($gemng)) { $magn[] = $ftmng; } $tpl->assign('mn', $magn); $db->free_result($gemng); I want to display a result with only 20 student not more than that. and display others in pages. how can I do that ... can you fix the code and add the pagination code to it ? do not worry about the html file I will take care of it 回答1: Here's a simple tutorial on how to code it

Stripping whitespace out of smarty templates from PHP

余生颓废 提交于 2020-01-13 19:15:21
问题 Is there a way to tell Smarty from PHP that you want it to strip all the whitespace in your templates before sending to browser, as if all your templates were embedded in {strip} tags? Some sort of Smarty object parameter or something? 回答1: In your Smarty plugin folder there is a filter that can be easily adapted to the task: it's outputfilter.trimwhitespace.php . Just add the line $source = preg_replace("`\s+`ms", " ", $source); (from the forum post linked by Martin) at line 51 and then call

Truncate a HTML formatted text with SMARTY

五迷三道 提交于 2020-01-13 15:00:11
问题 I've got a variable which is formatted with random HTML code. I call it to {$text} and i truncate it. The value is for example: <div>Lorem <i>ipsum <b>dolor <span>sit </span>amet</b>, con</i> elit.</div> If i truncate the text's first ~30 letters, I'll get this: <div>Lorem <i>ipsum <b>dolor <span>sit The problem is, I can't close the elements. So, I need a script, which check the <*> elements in the code (where * could be anything), and if it dont have a close tag, close 'em. Please help me

Wrong page number on setPage() function: 0

依然范特西╮ 提交于 2020-01-13 11:46:10
问题 My code for tcpdf is $file_to_show_test_details = 'pdf_view_test_details.tpl'; $test_details= $smarty->fetch($file_to_show_test_details); // Set some content to print $html = <<<EOD $test_details EOD; // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'XYZ',$pdf->writeHTML($html, true, false, true, false, '')); The function writeHTML is not working, that's why the error 'Wrong page number on setPage() function: 0' appears in the browser. Could anyone please

Checking for PHP session without starting one?

大憨熊 提交于 2020-01-12 06:45:02
问题 Is it possible to check for a session with out starting one? The reason that I ask is, the app I am developing has an integrated admin interface. So when an admin is logged in they browse the same pages as the users to make their edits. Fields and options are shown based on the users privs. This is causing two problems. One is Because a session is being started, I can not enable browser caching features as the headers being sent are always: Cache-Control: no-store, no-cache, must-revalidate,

Reconfiguring PHP Mail() Smarty Contact Form

筅森魡賤 提交于 2020-01-11 12:48:12
问题 I'm using Prestashop as my ecommerce shopping cart and CMS solution and was having problems receiving emails sent via the contact form. I asked around and found the problem to be due to the fact that I need to assign the 'from' address as something from my domain (e.g. do_not_reply@mydomain.com) and the email entered by user to be assigned a different variable (e.g. 'replyemail'). However, the Prestashop contact form is created with a PHP Smarty template engine, which has separate contact

Print all variables available in a Smarty template

走远了吗. 提交于 2020-01-10 11:52:19
问题 How do you print all variables available in the context of a Smarty template? Something like the Django debug trace that lists everything being passed. Thanks 回答1: Use {debug} From the manual: {debug} dumps the debug console to the page. This works regardless of the debug settings in the php script. Since this gets executed at runtime, this is only able to show the assigned variables; not the templates that are in use. However, you can see all the currently available variables within the

Print all variables available in a Smarty template

拈花ヽ惹草 提交于 2020-01-10 11:51:50
问题 How do you print all variables available in the context of a Smarty template? Something like the Django debug trace that lists everything being passed. Thanks 回答1: Use {debug} From the manual: {debug} dumps the debug console to the page. This works regardless of the debug settings in the php script. Since this gets executed at runtime, this is only able to show the assigned variables; not the templates that are in use. However, you can see all the currently available variables within the

How to Debug Variables in Smarty like in PHP var_dump()

僤鯓⒐⒋嵵緔 提交于 2020-01-10 06:20:09
问题 I have some variables inside a template and I don't know where I assigned them. I need to know what is inside a particular variable; for instance, say I have a variable in smarty called member . I tried with {debug} but it didn't work, and no popup was shown. How can I output/debug smarty variables using something like var_dump() inside the templates? 回答1: You can use {php} tags Method 1 (won't work in Smarty 3.1 or later): {php} $var = $this->get_template_vars('var'); var_dump($var); {/php}

DOMPDF: Unable to stream pdf: headers already sent

若如初见. 提交于 2020-01-10 03:02:53
问题 This question has been raised hundred of times in various fora; some have been solved, some not. I checked plenty of resources, but my issue could not be resolved. I am generating php page using smarty template based on html form input and uploaded files. Using dompdf, I want to save the generated page as a pdf file. When the user submits the multipart/form-data, data is posted to itself. Then it undergoes validation process. When all is fine, a new page is generated using a template file.