|
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 |
BbErSeRkK Smarty Rookie
Joined: 04 Jan 2008 Posts: 14
|
Posted: Wed Sep 23, 2009 7:14 am Post subject: add a prefix to a variable name (variable variable) |
|
|
I have a template that generates a dynamic table for db data
Code: |
<table class="tablesorter {$tableclass}" cellspacing="0" cellpadding="0" summary="{$table_caption}" id="{$table_id|default:'tblDispDBTable'}" >
<caption>{$table_caption}</caption>
<thead>
<tr>
{section name=hcols loop=$table_header}
|
i need to use two of these tables on the one page
when i do the include i think i can do
Code: | {include file="tblDynamic.tpl" table_header=$table1_header} |
but I was hoping to use a prefix on the variables instead
Code: |
<table class="tablesorter {$prefix+$tableclass}" cellspacing="0"
|
just wondering if this was possible |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Sep 23, 2009 1:20 pm Post subject: |
|
|
Not without an intermediate step:
Code: | {assign var="tmp" value="`$prefix`varname"}
{$tmp} |
|
|
Back to top |
|
BbErSeRkK Smarty Rookie
Joined: 04 Jan 2008 Posts: 14
|
Posted: Thu Sep 24, 2009 4:14 am Post subject: |
|
|
|
|
Back to top |
|
BbErSeRkK Smarty Rookie
Joined: 04 Jan 2008 Posts: 14
|
Posted: Fri Sep 25, 2009 1:23 am Post subject: |
|
|
ok for future reference i needed to do this to have it work properly, not sure if there is a better way?
Code: | {assign var=prefixed_table_rows value="`$tbl_prefix`table_rows"|varvar}
..
{section name=drow loop=$prefixed_table_rows}
... |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Sep 25, 2009 2:56 am Post subject: |
|
|
Assign names correctly from PHP and just loop with Smarty? |
|
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
|