|
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 |
scorpster Smarty n00b
Joined: 17 Feb 2012 Posts: 4
|
Posted: Fri Feb 17, 2012 12:01 pm Post subject: Translate {php} code to 3.1 compliant |
|
|
I am not a smarty template or php programmer.
I had somebody configure an existing package for me in 2010 but now the underlying package is using 3.1 smarty engine.
The following {php} code needs to be re-written/translated so that it works in the new environment.
{php}
if($_GET['b']==4){
$this->_tpl_vars['ppClass'] = 'class="hiddenDiv"';
}else{
switch($_GET['section']){
case 'price_plans':
$this->_tpl_vars['infoClass'] = 'class="hiddenDiv"';
break;
case 'personal_details':
$this->_tpl_vars['ppClass'] = 'class="hiddenDiv"';
break;
default:
break;
}
}
{/php}
Any help/suggestions/advice is greatly appreciated.
thanks,
C. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Feb 17, 2012 2:57 pm Post subject: |
|
|
This can all be done in templates without {php}.
Code: | {if $smarty.get.b == 4}
{assign var="ppClass" value='class="hiddenDiv"'}
{elseif $smarty.get.section == "price_plans"}
{assign var="infoClass" value='class="hiddenDiv"'}
{elseif $smarty.get.section == "personal_details"}
{assign var="ppClass" value='class="hiddenDiv"'}
{/if} |
|
|
Back to top |
|
scorpster Smarty n00b
Joined: 17 Feb 2012 Posts: 4
|
Posted: Fri Feb 17, 2012 3:19 pm Post subject: |
|
|
that's great - thanks ... now I've got passed that particular error, the next block "bad code" has emerged ... can you suggest proper edit for this for 3.1 compliance?:
{php}
$newAr = array(
'classified' => $this->_tpl_vars['cartLinks']['classified'],
'auction' => $this->_tpl_vars['cartLinks']['auction'],
'account_balance' => $this->_tpl_vars['cartLinks']['account_balance']
);
$this->_tpl_vars['cartLinks'] = $newAr;
{/php} |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Feb 17, 2012 5:12 pm Post subject: |
|
|
Code: | {$cartLinks = ['classified' => $cartLinks['classified'],
'auction' => $cartLinks['auction'],
'account_balance' => $cartLinks['account_balance']]} |
|
|
Back to top |
|
scorpster Smarty n00b
Joined: 17 Feb 2012 Posts: 4
|
Posted: Fri Feb 17, 2012 5:56 pm Post subject: |
|
|
Thanks for helping me -- I can't say how much I appreciate it ...
I got somebody to help me find the full set of code statements from the template file that have the same {php} tag. These code snippets will rear up at some point to throw errors -- thank goodness there are smarter people than me out there!
Based on the help I've received so far (and trying to show forum members that I do want to learn and not just be an annoying "noob") am I correct in translating the following:
{php}
$newArr = array(
'active_ads' => $this->_tpl_vars['links']['active_ads'],
'expired_ads' => $this->_tpl_vars['links']['expired_ads'],
'favorites' => $this->_tpl_vars['links']['favorites'],
'current_bids' => $this->_tpl_vars['links']['current_bids'],
'ad_filters' => $this->_tpl_vars['links']['ad_filters'],
'signs_flyers' => $this->_tpl_vars['links']['signs_flyers'],
'Facebook_Feed' => $this->_tpl_vars['links']['Facebook_Feed']
);
$this->_tpl_vars['links'] = $newArr;
{/php}
to
{$newArr = ['active_ads' => $links['active_ads'], 'expired_ads' => $links['expired_ads'], 'favorites' => $links['favorites'], 'current_bids' => $links['current_bids'], 'ad_filters' => $links['ad_filters'], 'signs_flyers' => $links['signs_flyers'], 'Facebook_Feed' => $links['Facebook_Feed']]}
...
Not sure about the translation of this one though:
{php}
$this->_tpl_vars['orderItemLinks'] = array();
{/php}
... or this one ...
{php}
$newArray = array();
foreach($this->_tpl_vars['paymentGatewayLinks'] as $linkArray){
if($linkArray['link']=="index.php?a=29"){
continue;
}
$newArray[] = $linkArray;
}
$this->_tpl_vars['paymentGatewayLinks'] = $newArray;
{/php}
Help is very much appreciated.
thanks again.
C. |
|
Back to top |
|
scorpster Smarty n00b
Joined: 17 Feb 2012 Posts: 4
|
Posted: Fri Feb 17, 2012 6:00 pm Post subject: |
|
|
oops ... found this one as well ...
{php}
$newArray = array();
foreach ($this->_tpl_vars[boxes] as $k => $v) {
switch ($v['title']) {
case 'Recently Sold':
$newArray[0] = $v;
break;
case 'Auctions':
$newArray[1] = $v;
break;
case 'Classifieds':
$newArray[2] = $v;
break;
}
}
ksort($newArray);
$this->_tpl_vars['boxes'] = $newArray;
{/php} |
|
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
|