Hello, I want to insert a little code php in .tpl file (I don't use smarty template). I searching in google some example with: {literal}{/literal}, but I cannot replace my code. This is my code: require_once("functions.php"); $some_name = $_GET['v']; echo '<input type="hidden" id="current_name" value="'. $some_name .'">'; Code (markup): I try but I can't do it, I don't know hou use: " and ' ! Thanks in advance for any help !!
You say you're not using smarty - then what are you using? Most examples are for smarty .tpl-files, and might not work with other templating engines. However, wrapping your code with either {php}{/php} or {literal}{/literal} should work. The code you presented seems to be correct PHP, and should work as long as the php is actually interpreted.
Sorry, I see now my website used smarty... I try like this, but don't work: {literal}require_once("functions.php");{/literal} {literal}$some_name = $_GET['v'];{/literal} echo {literal}'<input type="hidden" id="current_name" value="'. $some_name .'">';{/literal} PHP: I don't know how to do. If some one can help me ! Thanks !
I never used that, but have you tried this? {literal} require_once("functions.php"); $some_name = $_GET['v']; echo '<input type="hidden" id="current_name" value="'. $some_name .'">'; {/literal} PHP:
Did you try to change {literal} to {php}? And which version of Smarty are you using? Since that might change what works and not. You can also change the default rendering of PHP in the Smarty config, but that might not work either, depending on what version you're running.
I was try same this, but don't work.... {include file='some_functions.php' p="index"} {php} $some_name = $_GET['v']; echo '<input type="hidden" id="current_name" value="'. $some_name .'">'; {/php} Code (markup): Anyone can help write code ?
There is no need to change your code. You can simply allow PHP script to run in .tpl files by adding this line to your .htaccess file (provided your server supports one): AddType application/x-httpd-php .tpl Code (markup): This should allow PHP code to execute in all .tpl files in the directory. Remember to add the PHP start and end tags (<?php & ?>) before and after your code. Check out this article to learn more about the .htaccess file: https://blog.cocashcreators.com/a-guide-to-the-htaccess-file/