|
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 |
GodHunter Smarty n00b
Joined: 15 Jun 2015 Posts: 2
|
Posted: Mon Jun 15, 2015 6:26 pm Post subject: Block PlugIn returns twice |
|
|
Hi,
one of my blog functions returns twice and i dont know why.
If i return the $content it only shows returns one time, such as it should be, but when i try to return the mysql query it shows up twice ... maybe someone could help me. The Query works fine ...
Code: |
function smarty_block_title($params, $content, &$smarty, &$repeat){
$query = 'SELECT translation FROM **** WHERE parentID = '. $params['id'] .' AND locale = "'. $params['lang'] .'" AND type = 0 LIMIT 1';
$sql = mysql_query($query);
$row = mysql_fetch_array($sql);
if($row == false) return $content;
else return $row['translation'];
};
|
Code: |
{title id="{$mainslider[nr].parentID}" lang="{$langcode}"}{$mainslider[nr].title}{/title}
|
Just as i said $row['translations'] shows up twice when calling this ... |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Jun 15, 2015 10:08 pm Post subject: |
|
|
Also don't use "{ .. }" when passing parameter.
Code: | {title id=$mainslider[nr].parentID lang=$langcode}{$mainslider[nr].title}{/title} |
It has bad performance and forces parameter conversion to strings which might not be right in all cases. |
|
Back to top |
|
GodHunter Smarty n00b
Joined: 15 Jun 2015 Posts: 2
|
Posted: Tue Jun 16, 2015 6:13 am Post subject: |
|
|
Thanks for your help and tips, i will change the "{}" tags if i will output something. It also works to change the return by calling
Code: | if(!$repeat) return $row['translation']; |
Works fine now |
|
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
|