Hi
I’m having some difficulty getting to the bottom of an issue I’m having regarding replacing duplicate tagdata tags. Imagine the following:
Module:
class clientname_runners {
var $return_data = '';
function clientname_runners() {
}
function profile() {
global $TMPL;
$TMPL->tagdata = str_replace('{county}','22', $TMPL->tagdata);
return $TMPL->tagdata;
}
}
Template:
{exp:clientname:profile}
<select name="county" class="text">
<option {if "{county}"=="10"} selected="selected"{/if}>10</option>
<option {if "{county}"=="11"} selected="selected"{/if}>11</option>
<option {if "{county}"=="12"} selected="selected"{/if}>12</option>
<option {if "{county}"=="13"} selected="selected"{/if}>13</option>
<option {if "{county}"=="14"} selected="selected"{/if}>14</option>
<option {if "{county}"=="15"} selected="selected"{/if}>15</option>
<option {if "{county}"=="16"} selected="selected"{/if}>16</option>
<option {if "{county}"=="17"} selected="selected"{/if}>17</option>
<option {if "{county}"=="18"} selected="selected"{/if}>18</option>
<option {if "{county}"=="19"} selected="selected"{/if}>19</option>
<option {if "{county}"=="20"} selected="selected"{/if}>20</option>
<option {if "{county}"=="21"} selected="selected"{/if}>21</option>
<option {if "{county}"=="22"} selected="selected"{/if}>22</option>
<option {if "{county}"=="23"} selected="selected"{/if}>23</option>
<option {if "{county}"=="24"} selected="selected"{/if}>24</option>
<option {if "{county}"=="25"} selected="selected"{/if}>25</option>
<option {if "{county}"=="26"} selected="selected"{/if}>26</option>
<option {if "{county}"=="27"} selected="selected"{/if}>27</option>
</select>
{/exp:clientname:profile}
Rendered HTML
<select name="county" class="text">
<option >10</option>
<option >11</option>
<option >12</option>
<option </div>
...
As you can see, the template breaks after about the 3rd replacement of {country}.
What am I doing wrong?
Any advice greatly appreciated, I’m currently pulling my hair out over this.
Regards
If you strip your module to exactly what you have above (making your tag and class names match, obviously), do you find that you still have the problem? And what if instead of parsing a braced quoted variable, you prep the ‘county’ variable for use in a conditional ($FNS->prep_conditionals()) so you can use standard syntax?
{if county == '22'}foo{/if}
Hi Derek,
Apologies I’ve only just picked up these responses. I did manage to get to the bottom of it in the end - but can’t for the life of me remember what it was or how I fixed it, it was a couple of weeks ago now (and alot has happened since then!) :/
Thanks for the help.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.