PDA

View Full Version : Using options in scripts within template


Dr.CustUmz
02-15-2021, 01:50 PM
Ok for those who know me know im use to vb3, but I am working on something for vb4 and was wondering why my option wont print within a script in a template...

my code is as follows: (within a template)

<vb:if condition="$vboptions[drc_img] == ''">
$('[id^="post_message_"] img').css('display','none');
<vb:else />
$('[id^="post_message_"] img').attr('src','$vboptions[drc_img]');
</vb:if>
<vb:if condition="$vboptions[drc_notice]">
$('#notice').show();
</vb:if>

and my img src is printing as "$vboptions[drc_img]" rather than the option.

also another instance of this is that last div I show in the code above.

the div shows, but displays $vboptions[drc_notice] when it should be displaying the Text...

<div id="notice">$vboptions[drc_notice]</div>

shka
02-15-2021, 04:05 PM
the div shows, but displays $vboptions[drc_notice] when it should be displaying the Text...

<div id="notice">$vboptions[drc_notice]</div>

<div id="notice">{vb:raw vboptions.drc_notice}</div>

Dr.CustUmz
02-15-2021, 04:21 PM
<div id="notice">{vb:raw vboptions.drc_notice}</div>

THANK YOU!

is the vb:raw standard for all $ within templates in vb4 then?

shka
02-15-2021, 04:36 PM
For output/echo values use curly braces and for array use dot syntax instead of square brackets.

https://www.vbulletin.com/docs/html?manualversion=40205500 - search for "template syntax"
Raw Variables

To access variables in the normal, pre-vB4 fashion, use the following syntax:

{vb:raw variable}

This is equivalent to simply accessing $variable in the pre-vB4 syntax. No treatment is applied to the variable. The same dot operator is used to access array elements.

Dr.CustUmz
02-15-2021, 04:42 PM
Thanks shka (thinking in my head ShotKalla) lol