element scrubber| Good for dropdowns of form templates in NEWs etc...

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JeremyBASS

element scrubber| Good for dropdowns of form templates in NEWs etc...

Post by JeremyBASS »

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:

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
SimonSchaufi

Re: element scrubber| Good for dropdowns of form templates in NEWs etc...

Post by SimonSchaufi »

JeremyBASS wrote: Just thought I'd share that one... as I use it everywhere and it's super handy...
Hi!
could you show us an example as i have no idea what this is good for? not to criticize the code but i want to find out the potential that is in that code.
JeremyBASS

Re: element scrubber| Good for dropdowns of form templates in NEWs etc...

Post by JeremyBASS »

it's good to scrub element blocks ... in this case remove non-matching as shown... but you can modify a little and it can remove matching...

the template example above is the fesubmit for NEWS mod... so there it's scrubbing out categories the don't match the FEU user group... hope that makes better sense for you...

the point is that it's used for taking full element block out of the template based on the content of the element block... with out destroying the other surrounding elements.

Cheers
jeremyBass
Post Reply

Return to “Tips and Tricks”