We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Add varible to master page URGENT! | Forum

Topic location: Forum home » Support » General Questions
Marcus Aug 6 '18

I have wrapped my H1 tag in general.html master page with this:

{if $test}<h1 class="ow_stdmargin {$heading_icon_class}">{$heading}</h1>{/if}

I can't seem to find a way to pass $test = true value to there.

Please teach me how to pass or assign a variable on before page load?

JB TECH Aug 6 '18

The value and status of the $test variable is connected to the controller/component PHP file that coresponds to general.html.

You can use something like this in SMARTY to check the values:

{if $test == TRUE} {/if}

It's typically good practice, if you want a solid and defined value of a variable, to use double equals signs.

dave Leader
dave Aug 6 '18
+1 Jake 

However, to expand on this, in the html file to actually assign a value to a var in smarty (rather than the php file associated with it) you do it like this. 

{assign var=test value=TRUE}

Then do your value test using the smarty eq (equals) condition

{if $test eq TRUE}

<h1 class="ow_stdmargin {$heading_icon_class}">{$heading}</h1>


       <span>NO Header For You!! </span>


There is also ne (not equal), lt (less than), gt (greater than) and a few others.

The Forum post is edited by dave Aug 7 '18