How o use php in templates/default/container.tpl

laur

Avatar: laur

2012-09-24 20:11

I want the value that was inserted into the search-form to remain after i am redirected to the search results page
i use <input id="......" type="text" value="<?php echo htmlspecialchars($_POST['terms'])?>" />
I"ve used this :

How to execute a PHP code in templates? **

The script can execute a PHP code in templates. We don&#8217;t recommend this solution, but if it is necessary, please use it with consideration. To enable execution of a PHP code in templates:

edit the &#8220;database/config/general.php&#8221; file and change value of the &#8220;$config[&#8217;embed_php&#8217;]&#8221; variable to:

$config['embed_php'] = true;

edit any template from the &#8220;templates/default/&#8221; directory and insert the code there e.g.:

<?php phpinfo(); ?>

Templates with extension tpl can be viewed by an internet browser. We recommend to hide these files when PHP code is included in template files. In the &#8220;templates/default/&#8221; directory create a &#8220;.htaccess&#8221; file with content:

Options +Indexes
IndexIgnore *.tpl
<files *.tpl>
order allow,deny
deny from all
</files>


in the search box it shows me this message : Parse error: syntax error, unexpected , expecting ',' or ';' in /home/vhosts/sunpower.eu5.org/core/libraries/tpl-parser.php(120) : eval()'d code on line 1<br><center><a target='_blank' href='www.freewebhostingarea.com'><img src='users.freewebhostingarea.com/i/freehosting.png' border='0' width='88' height='15' alt='Free Web Hosting'></a></center>
the eval code is ok .... what should i do ?

» Quick.Cart v5.x

treewood (OpenSolution)

Avatar: treewood

2012-09-25 07:21

send link to your shop or template that you changed ... i will check it on my server

laur

Avatar: laur

2012-09-25 16:41

www.sunpower.eu5.org

laur

Avatar: laur

2012-09-25 18:48

the full archive of the script : www.sunpower.eu5.org/backups-1348591410.zip

treewood (OpenSolution)

Avatar: treewood

2012-09-26 06:55

you've done error in PHP code. change this code to:

<?php echo htmlspecialchars( isset( $_POST['terms'] ) ? $_POST['terms'] : null ); ?>

laur

Avatar: laur

2012-09-26 16:35

I've changed the code but still nothing , it don't save the form value and post it on the search page in the same search form .
Under <!-- BEGIN HEAD --> in container.tpl i've inserted <?php phpinfo(); ?>
I've changed <input id="s" type="text" value="<?php echo htmlspecialchars($_POST['terms'])?>" /> to this <input id="......" type="text" value=" <?php echo htmlspecialchars( isset( $_POST['terms'] ) ? $_POST['terms'] : null ); ?> " />
the form remains empty when i hit search button and i am redirected to the serch result page
my edited sites' source is www.sunpower.eu5.org/backups-1348669890.zip
I don't know what to do , can you give me the edited container.tpl ? or the whole form source from container.tpl ?

laur

Avatar: laur

2012-09-26 17:16

wooooooohoooo ! I've done it , all i had to do was to add name="terms" after <input id="s" :D --- Now the search script looks like this : ------> <!-- IF:START SEARCH-FORM -->
<form method="post" action="$sLinkSearch" id="searchForm2">
<fieldset>
<span> <label for="$lang[search]">$lang[search]</label><input id="s" name="terms" type="text" size="15" value="<?php echo htmlspecialchars( isset( $_POST['terms'] ) ? $_POST['terms'] : null); ?>" /></span>
<em><input type="submit" value="$lang[search] &raquo;" class="submit" /></em></span>
</fieldset>
</form><!-- IF:END SEARCH-FORM -->
-
Thanck you so much ! Now I have a fully functional Jquery google search in Quick.cart :p

Back to top
about us | contact