UDT to totally remove a variable

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

UDT to totally remove a variable

Post by psy »

I needed to remove a smarty assigned variable in some template logic - not just set its value to null. There is no plugin in CMSMS, at least to my knowledge, to do it. Solution was to create a UDT called 'clear_var'.

UDT:

Code: Select all

$smarty->clearAssign($params['var']);
and in my template:

Code: Select all

{clear_var var='myvar'}
This completely erased the variable, not just the assigned value.
Post Reply

Return to “Tips and Tricks”