smarty

Smarty kills my session

百般思念 提交于 2019-12-13 19:11:58
问题 I have a problem with Smarty 3.1.13. Smarty kills my session. Every time I refresh my page, $_SESSION array is empty. When I comment line $smarty->display('index.tpl') , everything is OK. Any ideas? 回答1: You have to start your session before $smarty->display('index.tpl') This is beacause the session cookie needs to be send in the HTTP header and therefore session_start will need to be called before the first line of output. So make sure session_start() is placed before $smarty->display('index

jquery in smarty tpl

余生长醉 提交于 2019-12-13 14:11:00
问题 jquery in smarty tpl -- Trying to use jquery to insert a class attribute so that I can CSS style every other list item row with shading. The following code seems as though it should work, but "alt" class is not getting inserted into li tag. Page loads fine -- no problems there. Anyone see something obviously wrong? {literal} <script src="{$content_dir}themes/pres2c/js/stripe/jquery-1.7.1.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery(".block_content li

{strip}: how to avoid unintended whitespace removal?

♀尐吖头ヾ 提交于 2019-12-13 12:33:40
问题 {strip} <div class="x" > {/strip} becomes <divclass="x"> And that is not what anyone would want. So, the question: is there any way to avod this? Imagined approaches: replace new lines by spaces, using parameters or other smarty-functions add protected spaces that are not stripped/trimed This topic on their forum doesn't have a solution, (other than - add your own custom tag). Also, please don't offer solutions in raw PHP or any other languages / frameworks. 回答1: You can either go with @dev's

php functions using with smarty template [closed]

拈花ヽ惹草 提交于 2019-12-13 10:00:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . please give some note about php functions using with smarty template 回答1: Smarty does allow you to call PHP functions, but it's assumed that you shouldn't need to and so it's not as easy as it could be. The

Get date for past weekday with Smarty

浪尽此生 提交于 2019-12-13 09:49:21
问题 I'm still fairly inexperienced with scripting, so my knowledge is limited to working with smarty. I'm working on building a daily news site, and we are going to have an archive of news articles from every day from the past week. If the day of the week hasn't yet passed, it will show the articles from that day of the week last week. On each day's page, I want a head line that says "News from Monday, June 10th" or whatever the date for the last one of those days of the week was. As far as I can

Smarty - include template and update an existing variable

有些话、适合烂在心里 提交于 2019-12-13 08:20:04
问题 I've recently started working with Smarty and I'm trying to find my way around. Here's what I don't know in the very moment: I'm including a file: {include file="nforum/_partials/box_forum.tpl"} In that file, I have this: <a href="{$t->link}">{$t->title|truncate:$link_truncate}</a> I would like to pass $link_truncate a value of 30 while including the template (not inside the box_forum.tpl - that's important to me!) I'm trying with: {include file="nforum/_partials/box_forum.tpl" $link_truncate

PHP smarty variable error

徘徊边缘 提交于 2019-12-13 07:15:56
问题 I have this error " NOTICE: UNDEFINED VARIABLE: LOGO IN C:\WAMP\WWW\SITE\TOOLS\SMARTY\SYSPLUGINS\SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL STACK" Here is my PHP code function hookFooter($params) { global $smarty; $smarty->assign('ENT_QUOTES', ENT_QUOTES); if( file_exists('modules/ebbrandingfooter/logo-footer.jpg')){ $smarty->assign('logo','modules/ebbrandingfooter/logo-footer.jpg'); }; $FOOTERdescription=Configuration::get('FOOTER_DESC'); $smarty->assign('description',$FOOTERdescription );

Frustrating Smarty Error : call to undefined function phperror_reporting

瘦欲@ 提交于 2019-12-13 07:14:59
问题 I am trying to upload my site onto the server but I keep getting the following error: Fatal error: Call to undefined function phperror_reporting() in /home/jagani/public_html/theforum/forumfiles.php on line 1 First few lines of the file are: <?php error_reporting(E_ALL^E_NOTICE); session_start(); Seems that the space between the php and error_reporting isn't being registered. I'd appreciate any insight on this problem. 回答1: As you said, it sounds like a problem with the whitespace. If you've

Variable Variable in Smarty Templates

百般思念 提交于 2019-12-13 06:23:54
问题 I have a dynamically generated Smarty variable in PHP. I want to access it with name , Say for example there is a smarty variable {$asdf} which was generated dynamically and i have an array that has 'asdf' i want to use this array and access {$asdf}. {$asdf} prints a input element [rendered] ; $array = array('asdf'); {foreach from=$array item=x} {$x} {/foreach} //but {$x} is not giving renderend input instead it is giving $asdf where am i going wrong? 回答1: It is generally atypical to do this

How to keep a specific value selected in a select HTML control in following scenario?

耗尽温柔 提交于 2019-12-13 06:19:29
问题 I'm using PHP, Smarty and MySQL for my website. I'm having a select control. The code for it is as follows: <select name="contact_label" id="set_contact_label"> <option value=""> -- Select label-- </option> {if $enquiries_labels} {foreach from=$enquiries_labels item=label key=key} <option value="{$key}" {if $contact_label == $key} selected="selected" {/if}>{$label}</option> {/foreach} {/if} </select> Equivalent HTML output is as follows: <select name="contact_label" id="contact_label">