We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

replacing (duplicate) tagdata {tags}

Development and Programming

viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

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

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

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}
       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Also, what version and build of ExpressionEngine are you on? There’s a very obscure bug with conditionals in an older build that might be at play here.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Did an update help you, viewcreative, or do you need some additional assistance?

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

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.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

No problem, viewcreative, glad you got it working!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.