vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Conditional Templates Hack (https://vborg.vbsupport.ru/showthread.php?t=21489)

dp  06-28-2001 01:50 PM

Hi,

maybe you know that problem, just checking if $foo isset, if not dont display option $bar.

this is kinda nasty cuz you gotta edit the .php file and the template.

i've thought about conditional templates and wrote that extremly short hack:

./admin/functions.php

before
PHP Code:

if ($gethtmlcomments and $addtemplatename) { 

paste this
PHP Code:

$template=str_replace('?','"',$template); 

this will replace every ?-char with " but it will NOT escape this quote char!

from now on you can use the iif() function:

Template:
Code:

... this user has ? . iif($userposts == 1, ?one post?, ?$userpost posts?) . ? since ...
actually it will look like this after beeing parsed:
Code:

... this user has " . iif($userposts > 0, "not a single post", "$userpost posts") . " since ...


well thats not easy to explain, i hope you got then point :rolleyes:

note this isnt tested very well, use with care!

mwagstaff 08-14-2002 11:49 PM

Awesome! This is just what I've been looking for for a long time. Fantastic work! From my quick-and-dirty testing, this appears to be the answer to my conditional templates dreams... :D

Dean C 08-15-2002 07:17 AM

what is the point of this :S?

mwagstaff 08-15-2002 10:35 AM

It allows you to include conditional statements in your templates. For example, on my site which is PDA-oriented, I want to display a different layout if a visitor is using a PDA browser (e.g. Pocket Internet Explorer), which obviously has a lot less screen space to play with.

Therefore, I would include a conditional check to see whether a PDA browser is detected or not before deciding which elements of the template to display, and what the layout should be.

Dark_Wizard 08-15-2002 10:44 AM

Conditional templates will be a feature of vb3....

Boofo 08-15-2002 10:45 AM

I still don't get it. Any examples of this in use? :)

Quote:

Originally posted by mwagstaff
It allows you to include conditional statements in your templates. For example, on my site which is PDA-oriented, I want to display a different layout if a visitor is using a PDA browser (e.g. Pocket Internet Explorer), which obviously has a lot less screen space to play with.

Therefore, I would include a conditional check to see whether a PDA browser is detected or not before deciding which elements of the template to display, and what the layout should be.


mwagstaff 08-15-2002 10:53 AM

I'm still checking, but it appears that the conditional check doesn't work correctly in the postbit templates - the result always comes up as false. :(

mwagstaff 08-19-2002 11:50 PM

Anyone know what's so special about the postbit templates that they set all variables to null?

For example, if I set a variable $mobile to 1, it will be recognised as such in the showthread template. In the postbit template, however, it always comes up as null (even if I include a php file in the postbit template that specifically sets it to 1).

Entourage 08-22-2002 03:20 PM

Quote:

Originally posted by mwagstaff
Anyone know what's so special about the postbit templates that they set all variables to null?

For example, if I set a variable $mobile to 1, it will be recognised as such in the showthread template. In the postbit template, however, it always comes up as null (even if I include a php file in the postbit template that specifically sets it to 1).

Yes the variables are shipped to another php file (postbit is parsed in /admin/functions.php)

Xenon 08-22-2002 04:15 PM

it's because getpostbit is a real function, so it doesn't use variables from showthread.php
you have to globalize your variable first ;)


All times are GMT. The time now is 08:04 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.01973 seconds
  • Memory Usage 1,730KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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