|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mechatron Smarty n00b
Joined: 24 Aug 2020 Posts: 1
|
Posted: Mon Aug 24, 2020 3:36 pm Post subject: How to remove {php} tags and add plug ins ? |
|
|
Hello everyone!
I am quite new in smarty and also in coding. I will be really happy if you guys help me to work out because i am quite stuck on it now.
I would like to separate php code from tpl file. I don't have any plugin folder or path in my test env. This is what i tried recently:
in web-site/products/index.tpl.html file;
Code: |
{include file="plugins/function.shoe-size.php"}
{foreach from = $shoe_sizes item=shoe}
{if $info.return eq $shoe and $info.return|substr:0:1 != "0"}
<p style="font-weight:bold;display:inline;border-bottom:solid 1px black;">SHOE: </p>
{/if}
{/foreach} |
in web-site/plugins/function.shoe-size.php:
Code: | <?php
/**
* Smarty plugin
*/
/**
* Smarty {url} function plugin
*
* Type: function
* Name: Shoe Size filter
*/
function smarty_function_shoeSizes() {
$shoe_sizes = array(3,4,5,6,7,8);
return $shoe_sizes;
}
?>
|
This is the error:
Unable to load template 'file:plugins/function.shoe-size.php' in 'products/index.tpl.html'
How can i write this plugin properly ? Is there another way to solve this apart from plugin~ ?
(i have too many {php} problem in my code(comes form smarty2) so i need to learn proper solution.
Thanks a lot! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Aug 26, 2020 1:45 pm Post subject: |
|
|
Remove that {include}. Read the documentation, plugins are automatically loaded if named appropriately. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|