element scrubber| Good for dropdowns of form templates in NEWs etc...
Posted: Mon Jan 12, 2009 9:35 pm
Hello, so I needed to scrub out categories for the fesubmit in News... The thing was, I didn't want some users to be able to post an article if they were not of that group.
So the setup for the categories were the name of the catagories match the name of a property of the user groups... that is how this example is written... BUT this can been done to filter any thing that doesn't match...
So in this case
this gets the user property, it's a UDT you can find here in the forums.... you could use groups or username or what have you...
{get_feu_properties username=$username property="shrine_club" method="assign"}
this scrubs the dropdown for the $shrine_club pulling the full option out of the non matching option in the select element...
{assign var=inputcategory2 value=$inputcategory|regex_replace:"/]*>((?!`$shrine_club`)[^/":""}
note the backticks for the var
and this is the new dropdown call
{$inputcategory2}
this is a template ex:
now this can be done any where as this is a element scrubber so ... few more examples...
let say you had a list a tag popped out formed like this (thinking menu on this)
dog
dog toys
cat
cat toys
If you target dogs because you didn't want that to show cats then you scrub the and dog
{assign var=List2 value=$List|regex_replace:"/]*>((?!dog)[^/":""}
producing
dog
dog toys
or Now I what to show items with toys only so :
{assign var=List2 value=$List|regex_replace:"/]*>((?!toys)[^/":""}
will produce
dog toys
cat toys
Now these examples have just stripped out the items... what else can I do with this you ask? How about add new to a product... or a class to those s etc.... and you can set this remove what it has.
Just thought I'd share that one... as I use it everywhere and it's super handy...
Cheers
jeremyBass
So the setup for the categories were the name of the catagories match the name of a property of the user groups... that is how this example is written... BUT this can been done to filter any thing that doesn't match...
So in this case
this gets the user property, it's a UDT you can find here in the forums.... you could use groups or username or what have you...
{get_feu_properties username=$username property="shrine_club" method="assign"}
this scrubs the dropdown for the $shrine_club pulling the full option out of the non matching option in the select element...
{assign var=inputcategory2 value=$inputcategory|regex_replace:"/]*>((?!`$shrine_club`)[^/":""}
note the backticks for the var
and this is the new dropdown call
{$inputcategory2}
this is a template ex:
Code: Select all
{* original form template *}
{if isset($error)}
<h3><font color="red">{$error}</font></h3>
{else}
{if isset($message)}
<h3>{$message}</h3>
{/if}
{/if}
{$startform}<br/>
<h3>You are adding a new entry</h3>
<div class="pageoverflow">
<p class="pageinput"><strong><font color="#CC3300">*</font>{$titletext}:</strong>{$inputtitle}</p>
</div>
<div class="pageoverflow">
<p class="pagetext"><strong>When would you like it to show:</strong></p>
<p class="pageinput">{html_select_date prefix=$startdateprefix time=$startdate end_year="+2"} {html_select_time prefix=$startdateprefix time=$startdate}</p>
</div>
<div class="pageoverflow">
{get_feu_properties username=$username property="shrine_club" method="assign"}
{assign var=inputcategory2 value=$inputcategory|regex_replace:"/<option[^>]*>((?!`$shrine_club`)[^<])*<\/option>/":""}
<p class="pageinput"><strong>{$categorytext}:</strong>
{$inputcategory2}
</p>
</div>
{if !isset($hide_summary_field) or $hide_summary_field == 0}
<div class="pageoverflow">
<p class="pagetext"><strong><font color="#CC3300">*</font>Write a Short discription:</strong></p>
<p class="pageinput">{$inputsummary}</p>
</div>
{/if}
<div class="pageoverflow">
<p class="pagetext"><strong><font color="#CC3300">*</font>{$contenttext}:</strong></p>
<p class="pageinput">{$inputcontent}</p>
</div>
<div class="pageoverflow">
<p class="pagetext"> </p>
<p class="pageinput">{$hidden}{$submit}{$cancel}</p>
</div>
{$endform}
now this can be done any where as this is a element scrubber so ... few more examples...
let say you had a list a tag popped out formed like this (thinking menu on this)
dog
dog toys
cat
cat toys
If you target dogs because you didn't want that to show cats then you scrub the and dog
{assign var=List2 value=$List|regex_replace:"/]*>((?!dog)[^/":""}
producing
dog
dog toys
or Now I what to show items with toys only so :
{assign var=List2 value=$List|regex_replace:"/]*>((?!toys)[^/":""}
will produce
dog toys
cat toys
Now these examples have just stripped out the items... what else can I do with this you ask? How about add new to a product... or a class to those s etc.... and you can set this remove what it has.
Just thought I'd share that one... as I use it everywhere and it's super handy...
Cheers
jeremyBass