vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using options in scripts within template (https://vborg.vbsupport.ru/showthread.php?t=328593)

Dr.CustUmz 02-15-2021 01:50 PM

Using options in scripts within template
 
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)

Code:

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

Code:

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

shka 02-15-2021 04:05 PM

Quote:

Originally Posted by Dr.CustUmz (Post 2606273)

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

Code:

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

Code:

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

Dr.CustUmz 02-15-2021 04:21 PM

Quote:

Originally Posted by shka (Post 2606276)
Code:

<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?...rsion=40205500 - search for "template syntax"
Quote:

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


All times are GMT. The time now is 06:52 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01030 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete