vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   News flash: conditionals rock (https://vborg.vbsupport.ru/showthread.php?t=56500)

filburt1 08-26-2003 05:26 PM

News flash: conditionals rock
 
I've been porting vBMS to vB3 and am working on the navbar. Previously it took me a ton of regular expressions and multiple templates, but check it out:
Code:

<if condition="$iscurrentscript"><b><else /><a href="$filename?$session[sessionurl]"></if>
$title<if condition="$iscurrentscript"></b><else /></a></if>

<if condition="$isinbox and $unreadcount > 0">
    (<span style="color:{vbms_unreadtext}">$unreadcount</span>)
</if>

<if condition="!$islast">
    {vbms_navbar_delimiter}
</if>

One template, and it all works flawlessly. It sure must have saved the developers a ton of time when making templates...

Only problem is that it doesn't let you use custom functions. You can only use built-in ones like empty(), isset(), etc. :(

Neo 08-26-2003 05:37 PM

wait a min... didnt we talk about a hack like this once O_O?

I could make something like this pretty easy if you wanted it..or do you have it already? Adding functions wouldnt be that hard, just list the ones you think would be useful.

filburt1 08-26-2003 06:47 PM

I know a hack like this exists for vB2, but vB3's are already painless. :)

Also, IIRC the validation is only done when you make the template from the admin CP. Directly in the database, it won't be validating anything ;)

Xenon 08-26-2003 07:55 PM

in template.php there is a list of all allowed functions in template conditionals.

as for vb.org's vb3 i was already forced to add some functions to the list.
it's just as a security issue, if you'd allow DB changing functions the admin securitysystem would be useless...

filburt1 08-26-2003 08:56 PM

Well I'm assuming that phpinclude is disabled in such a case as well...

Neo 08-26-2003 09:46 PM

soon you wont even need to learn PHP to make fuull web applications. @_@

Tony G 08-27-2003 02:05 AM

Mmmm conditionals. :D

Erwin 08-27-2003 04:40 AM

Conditionals are great. In fact, what took multiple custom templates now all resides in the templates "memberinfo" or in "modify" using simple REQUEST variables. :)


All times are GMT. The time now is 01:06 AM.

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.01692 seconds
  • Memory Usage 1,721KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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