Ad Space
Ad Space

Hosting Geared For
your CMSMS needs

CMSMS ready Hosting

Hosting Starting at $15

  • • Hosted Mail
  • • Personal Control Panel
  • • CMSMS 1.8.1 tested
  • • Lightly packed servers
  • • Intrusion Detection
  • • URL monitored
  • • Custom solutions available

Order your hosting Now

CP Blogs

Related items / element

Posted by: Jeremy Bass
on May 24, 2009

Category:

CMS Made Simple, Smarty, Basics, Coding

Summary:

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.


Ad Space

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`)[^<])*<\/option>/":""}

note the backticks for the var and this is the new dropdown call {$inputcategory2}

this is a template ex:

  {* 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:"/]*>((?!`$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">&nbsp;</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)
<ul >
<li>dog</li>
<li>dog toys</li>
<li>cat</li>
<li>cat toys</li>
</ul>

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)[^<])*<\/li>/":""}

producing

<ul >
<li>dog</li>
<li>dog toys</li>
</ul>

or Now I what to show items with toys only so :

{assign var=List2 value=$List|regex_replace:"/]*>((?!toys)[^<])*<\/li>/":""}
will produce
<ul >
<li>dog toys</li>
<li>cat toys</li>
</ul>

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 is 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

Ad Space

Get Social With It

[+]

Add A Comment

[+]

Code in the picture:
Title:
Your Name(*):
Email:
Notify me of any further comments to this thread:
Website:
Comment(*):
 
Previous page: Hosting FAQ Next page: Experimental