The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Advanced Templates: Dynamic Templates Changing according to different conditions Details »» | |||||||||||||||||||||||||||
Advanced Templates: Dynamic Templates Changing according to different conditions
Developer Last Online: Nov 2023
This hack allows you to design dynamic vb templates which change themselves according to different conditions. Thus you can customize your board very powerfully with "intelligent/interactive" templates. It uses the same "conditional concept" just like my Webtemplates and Dynamic Forum Announcements Hack. With conditionals you can program your templates to:
The Hack's Features:
Vbulletin v.3 has been announced to have "conditional" concept in templates, however my hack wasn't inspired by it at all, because I'm using the conditionals in my Webtemplates hack since March 2002 so in fact vb developers might be inspired by me. My Dynamic Forum Announcements hack uses the same concept for forum home announcements too.. (Wait for my other hacks depending on conditionals cause I really like them, they are really powerful and customizable) Performance Issues The hack does NOT add any MYSQL connections. It just process your already retrieved templates in a function to parse the hack conditionals. Thus the performance is IMO quite bearable. However please notice that if a template has a conditional in it, the hack have to parse it before displaying it and technically this parsing is done with PHP's preg_match command which is known as a powerful but slow command. So does it cause any performance problems? In most cases no. But if the conditionals are applied in a very frequently used and/or long template and/or you used too many conditionals in one template AND your traffic or server load is high, this MAY increase your PHP processing time whenever this template is displayed as the hack has to deal with the conditionals everytime this template is called. I suggest applying Teck's Microstat's hack and observe the PHP running time with that hack after you applied a conditional especially in a frequently used template (eg. postbit). If it slows down the display, simply reduce your conditional count in that template or delete the conditional or remove the hack altogether. Personally I dont have any performance problems in my own board related to this hack but just wanted to give my 2 cents anyway especially for high-traffic boards.. If you liked the hack (I guess you will), I strongly suggest checking out my Webtemplates hack which provides exactly the same feature for your NON-VB pages. Also please click INSTALL if you use the hack, thank you.. 09.Sep.2002 Bug Fix: If you installed the hack before 09.Sep.2002 please download the instructions again and reapply step 2, since I made an update for a small bug fix. There was a variable name collision which causes a problem with email validation screen which uses the same variable so I changed my variable's name. If you are downloading the hack now, go ahead.. The code you download is already fixed.. 07.Oct.2002 UPDATE: I updated the hack code, so that people who have enabled template debugging in their Admin CP/vb Settings can also use the hack. Also small modification applied to increase template parsing time. If you installed the hack before my update, you may choose to reinstall (not necessary). If you are a new hack user, the instructions you download is already new version's. Enjoy! Logician \\=^)) Show Your Support
|
Comments |
#2
|
||||
|
||||
Screenshot?
umm what kind of screenshot I can provide you is not clear to me Still reserved in case someone has an idea though.. lol |
#3
|
||||
|
||||
After you installed the hack, you can apply some of these template modifications which you may enjoy. Please share your useful template modifications with other hack users in the thread and if you get the concept please help me out answering questions regarding conditionals here. Thank you!
BTW. Some examples may seem irrelevant to you but please notice that my intention is also to give you conditional samples so that you get the grips. Hide attachments in the thread from viewer if his registration date is newer than 2 weeks: edit template postbit_attachment and just in the begining add: [[($bbuserinfo[joindate]>strtotime(-2 weeks)]] and at the end add its closing tag: [[/($bbuserinfo[joindate]>strtotime(-2 weeks)]] Displays poster profile field 1 in postbit to Admins: (So you can access Admin only fields of user in postbit) Edit postbit template add PHP Code:
Hides User's Username in postbit if viewer is a guest Edit postbit template replace $post[username] as PHP Code:
Send entire message text with notification mail if forumid is Y edit email_notify add: [[($foruminfo[forumid]==Y)]]$message[[/($foruminfo[forumid]==Y)]] |
#4
|
||||
|
||||
Conditionals Help
If you are using my WebTemplates Hack or Dynamic Announcements: Programmable Forum Home Announcement/Message with conditionals Hack, this hack's conditionals are exactly same with these hacks'. Here is the conditional syntax: (it's strict in syntax so please apply correctly!) [[(your conditional)]] HTML code posted in template if condition applies [[/(your conditional)]] Conditional Rules: * Conditionals are covered inside [[ ]] tags * Conditional (both opening and closing) itself is in paranthesis ( ) * HTML codes are written in between the conditional tags and they are displayed in the template if condition applies * Opening and closing conditional are exactly same except closing conditional has a / right before ( * If you are trying to check if X equals to Y, use DOUBLE equation mark not single. eg. Correct: X==Y Incorrect:X=Y * You can design as many conditional as you like. If more than 1 condition applies at the same time, ALL applying conditionals HTML codes are parsed and all not-applied conditionals and their HTML code is automatically deleted when template is displayed. Some examples will help you understand the rules better. Here are some conditionals and their instruction texts which explains what that conditional do: (Consider HTML codes is in between instead of instruction texts and they are parsed if condition applies) * [[($bbuserinfo[userid]==32)]] Display this HTML code if page visitor's user id is 32 [[/($bbuserinfo[userid]==32)]] * [[($bbuserinfo[usergroupid]==5)]] Display this HTML code if page visitor's usergroupid is 5 (=if he is a Super Mod) [[/($bbuserinfo[usergroupid]==5)]] * [[($bbuserinfo[usergroupid]==1)]] Display this HTML code if page visitor is a guest [[/($bbuserinfo[usergroupid]==1)]] * [[($bbuserinfo[userid]>1)]] Display this HTML code if page visitor is NOT a guest [[/($bbuserinfo[userid]>1)]] * [[($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]] Display this HTML code if page visitor's a Super Mod OR a Mod OR an Admin [[/($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==7)]] * [[($bbuserinfo[posts]<10)]] Display this HTML code if page visitor has less than 10 posts [[/($bbuserinfo[posts]<10)]] * [[($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime("-30 days"))]]Display this HTML code if page visitor has not visited your board for 30 days[[/($bbuserinfo[lastvisit] and $bbuserinfo[lastvisit]<strtotime("-30 days"))]] * [[($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]]Display this HTML code if page visitor registered in a date between 2 weeks to 4 weeks from now[[/($bbuserinfo[joindate]>strtotime("-2 weeks") AND $bbuserinfo[joindate]<strtotime("-4 weeks"))]] You can use conditionals together too. Here is an example: -=-=-=-=-=-=-=-=-=-=-=-=-=-= [[($bbuserinfo[userid]==32)]] HTML Codes 1[[/($bbuserinfo[userid]==32)]] [[($bbuserinfo[usergroupid]==3)]] HTML Codes 2 [[/($bbuserinfo[usergroupid]==3)]] HTML Codes 3 -=-=-=-=-=-=-=-=-=-=-=-=-=-= When this template is called the hack will : Display HTML Codes 1, if user's userid = 32 Display HTML Codes 2, if user's usergroupid = 3 (=email confirmation waiting members) and always display HTML Codes 3 (it's out of conditionals) What if user 32 is also from user groupid 3? He will be BOTH displayed HTML Code 1 AND 2 because both conditionals are parsed if they applies. Another example of how you can design a multi-template: -=-=-=-=-=-=-=-=-=-=-=-=-=-= [[($bbuserinfo[posts]<30)]] <Your Templates default HTML Code here > [[/($bbuserinfo[posts]<30)]] [[(!($bbuserinfo[posts]<30))]] You dont have permission to access this page! [[/(!($bbuserinfo[posts]<30))]] -=-=-=-=-=-=-=-=-=-=-=-=-=-= When you use this code in any of your template, if page visitor's post number is less than 30, he will be displayed "You dont have permission to access this page!" but any other users will see the template. My Support for this hack: Just like all my other hacks I support this hack for any installation problems, bugs etc. (very unlikely there will be any) but as you would hopefully understand it's impossible for me to support the hack about forming your "conditionals". I give you detailed how-to instructions and samples and but there can be thousands of conditional designs people might ask for and it's not possible for me to answer all the time one by one. I dont discourage you to ask them away here in this thread so be my guest if you need help, but please forgive me if I cant personally answer you about these requests and I hope that other hack users will help out in the thread for these requests.. (While asking it can help if you give your failed samples).. Thanks for understanding.. |
#5
|
||||
|
||||
Very cool
*installs* Satan |
#6
|
||||
|
||||
Aww man, this is Ace! Brilliant work! Gonna instal this!!
|
#7
|
||||
|
||||
Fantastic, absolutely bloody fantastic.
|
#8
|
||||
|
||||
I just installed this hack and now my index.php page won't load!
|
#9
|
||||
|
||||
Did you make sure you did the modifications to :
admin/functions.php Satan |
#10
|
||||
|
||||
Quote:
2- Make sure you understand how to apply a conditional to your templates before taking actions. If you inserted a wrong conditional simply delete it from your template and you'll be just fine again. I strongly suggest you to work on how-to post and understand the conditional syntax before playing with your templates. Hack code is tested and working ok. But this is a powerful so a little bit tricky hack especially in usage (in fact this makes it powerful) so please take your time first to understand the basic concepts so that you wouldnt have any problems.. |
#11
|
||||
|
||||
this is just too good to be true
awesome hack mate - Mist |
#12
|
||||
|
||||
In one sentence what does this do?
|
#13
|
||||
|
||||
Look at the thread title if you really want it in one sentence -_-...
I have to say I am AMAZED by your hacks Logician. They have so much functionality and are so much more advanced than most other hacks. Great job, keep up the good work . |
#14
|
|||
|
|||
Another brilliant hack by Logician
Well done and thankyou |
#15
|
||||
|
||||
Quote:
Since you are a hacker this information can clarify things better for you: After you installed the hack you dont need to hack vb. code for this: PHP Code:
PHP Code:
|
#16
|
||||
|
||||
Simply amazing. A definate nomination for vB hack of the month, hell, hack of the year. This will revolutionize the way people hack their boards, I know I have a lot of uses for this hack just by reading through the description.
/me installs. |
#17
|
||||
|
||||
Absolutly a genious mod! Clicks install in a string
I guess this opens the way for creative codehackers to create new, funny and smart hacks for the VB forum. |
#18
|
|||
|
|||
Quote:
https://vborg.vbsupport.ru/showthrea...t=conditionals Like I said though, great hack and thanks... I'll be using it. |
#19
|
||||
|
||||
Quote:
So they might not be inspired by me, but at least I'm not inspired by them either.. :knockedout: |
#20
|
|||
|
|||
Great hack!
Using conditionals will it be possible to have separate templates for categories of forums? Or will you have to have a conditional for each forum in that category. I'm basically going to aim to have separate sections of my forum with different graphical styles etc. Thanks -Abbas |
#21
|
||||
|
||||
Quote:
Example: PHP Code:
However I might say that if you are trying to apply different styles for different forums you dont need a hack, you can do it by configuring your forum styles.. I believe you already know that? |
#22
|
|||
|
|||
Thanks for that info. Yeah I know different styles can be done without hacks, but there may be different templates involved not just graphical styles alone, e.g. our gaming forums may have other templates for clan and multiplayer stuff etc...
-Abbas |
#23
|
|||
|
|||
Does this work ok with 2.2.6? I installed it as per instruction but conditional tests simply get reflected back unchanged.
I tried the advanced_functions code as a stand alone and it seems fine. Perhaps I've made a silly mistake somewhere |
#24
|
||||
|
||||
Quote:
More likely your condition didnt apply so it wasnt parsed. What condition did you test and where? |
#25
|
|||
|
|||
Wow! I can't wait to try this out!
/me clicks install button |
#26
|
|||
|
|||
Sorted out my problem re conditionals not getting parsed.
gettemplate actually contains two return statements - the first executed only if you have enabled template debugging. I had this option enabled, so the call to advanced_templates was not being made. you need to make the following change to gettemplate PHP Code:
|
#27
|
|||
|
|||
This looks great! I have two questions with how it might work:
1) Is the html between the conditionals parsed, that is if I use a variable name in the html there will it be replaced with its value or will it stay as-is? 2) Can I put a "virtual include" in there in the html conditional? I've done this before using php-include template, but I'm wondering if I can get around that. Many thanks, Matt |
#28
|
||||
|
||||
Hi Matt,
Quote:
The hack only checks the template if there is special conditional tags inside and acts like this: a) if the template does not include any conditional, it takes no action and returns the entire template just like a normal vb. template. b) If the template has conditionals, the hack checks them one by one and ba) if condition is FALSE, it deletes this condition (and its HTML code in between) from the template, as if it never existed in the template bb) If condition is TRUE, it deletes only the condition tags and keeps the condition's HTML code in between so that it will be parsed. As you see it does not interfere with vb's default template processing in anyway.. Hope this helps.. |
#29
|
|||
|
|||
hi
will this edit all my style templates if I just edit the template of one style? thanks |
#30
|
||||
|
||||
Quote:
|
#31
|
|||
|
|||
Sorry to tell you this...
There is an obscure bug when this hack is installed, a user forgets his password and he requests a new one. One ends up with a PHP parse error. The bug is as follows: VBulletin uses $a as a global variable in the reset password code (around line 174 of member.php). This messes up use of $a as the command argument in advanced_templates. Solution: use a variable in advanced_templates which does not have global scope. (e.g. replace $a by $basictemplate) |
#32
|
||||
|
||||
Quote:
Since you wisely noticed the bug and its cause, I'm sure you already fixed it in your board but if you didnt, you can get the updated file and correct the problem.. Thx for the feedback though.. |
#33
|
|||
|
|||
You're too quick for me, Logician - or rather I'm too slow and bleary eyed by this time of day
Have now clicked on install, so that you can duly tell me the next wonderful things you achieve |
#34
|
|||
|
|||
i am seeing
[[(6==6)]] Advanced Templates Hack has been successfully installed! By the way this remark is visible to Site Admins only.. Enjoy.. Logician \\=^)) [[/(6==6)]] in the index.php page. how do i get rid of the [[(6==6)]] and [[/(6==6)]] so i will only see the message? just checked and seeing [[(2==6)]] Advanced Templates Hack has been successfully installed! By the way this remark is visible to Site Admins only.. Enjoy.. Logician \\=^)) [[/(2==6)]] in the index.php page. how do i get rid of the [[(6==6)]] and [[/(6==6)]] anyone else having this problem? |
#35
|
||||
|
||||
Quote:
As for technical details: 1. You can do if/else constructs 2. The conditionals are parsed at the time you edit your templates since we now store two copies of every template. One with the conditionals asis, and one with any conditionals converted to accompanying php code so that there is no overhead when the templates are called by the forum. |
#36
|
||||
|
||||
Quote:
|
#37
|
||||
|
||||
Quote:
Quote:
Of course I'm sure you have a nice algorithm either.. |
#38
|
||||
|
||||
perhaps you've read that already, but if not:
http://www.vbulletin.com/forum/showt...3&pagenumber=2 |
#39
|
||||
|
||||
Quote:
It's just a "substr_count" that's saved (which I intend to add to my hack too) but IMO it does not effect running time so significiantly.. Or I still didnt get how it will work? lol |
#40
|
|||
|
|||
what is this like on server load? it seems to be pretty hard on my site. any ideas?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|