vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Advanced Templates: Dynamic Templates Changing according to different conditions (https://vborg.vbsupport.ru/showthread.php?t=43325)

Logician 09-23-2002 08:27 AM

Quote:

Originally posted by trainer
what is this like on server load? it seems to be pretty hard on my site. any ideas?
IMO it's performance is quite good. For once there is no extra SQL connection this hacks creates on your site so it doesnt increase MySQL load. As for PHP performance, it's quite bearable and the increase is very trivial (at least in my site). Check my message a few lines above for its reason. But if you want to make sure, install Nakkid's (Teck) microstats hack and check the PHP running time before and after the hack. There is no significant load in my site..

But if you want to improve the performance better, here is a code I was already planning to add to the hack:

edit functions.php, find:
PHP Code:

return advanced_templates($template); 

Replace it AS:
PHP Code:

if (substr_count($template,'[[/(')>=1)
{
return 
advanced_templates($template);
}
else
{
return 
$template;


This will stop parsing for regular templates (=not having conditionals inside) thus will increase the performance..

BTW. Did my suggestion work for your problem?

trainer 09-23-2002 01:23 PM

once again thanks for the reply Logician. your sugestion worked for my first problem. didn't even know what that was until you pointed it out!

Marshalus 10-02-2002 04:19 PM

Does anyone know if this adds any additional DB queries?

Logician 10-02-2002 04:37 PM

Quote:

Originally posted by Marshalus
Does anyone know if this adds any additional DB queries?
No it does not..

Please check 2 posts above..

BlueVoltage 10-04-2002 04:42 PM

I tried installing this twice! I keep getting this error:

Quote:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xelerix/public_html/x/admin/functions.php on line 823

Fatal error: Call to undefined function: vbdate() in /home/xelerix/public_html/x/admin/sessions.php on line 407

BlueVoltage 10-04-2002 04:42 PM

I tried installing this twice! I keep getting this error:

Quote:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xelerix/public_html/x/admin/functions.php on line 823

Fatal error: Call to undefined function: vbdate() in /home/xelerix/public_html/x/admin/sessions.php on line 407

Logician 10-04-2002 05:36 PM

Quote:

Originally posted by BlueVoltage
I tried installing this twice! I keep getting this error:

If you are sure you applied step 2 correctly (it is REPLACE AS, not insert BEFORE or AFTER, and make sure you changed the file in Notepad), post here your functions.php just lines between 810 - 850, not the whole file) and let me see what you did wrong..

BlueVoltage 10-04-2002 10:17 PM

i got it now. sorry. GREAT HACK!!!

mikey8270 10-04-2002 11:07 PM

great hack :)

is there any way to make it show like 'You have relied to this thread' or You have not replied to this thread' somewhere on the showthread page to everybody except guests?

g-force2k2 10-05-2002 02:32 AM

meh... okay Logician buddy im looking to you for support now :p

anways i get the infamous 6==6 as stated in the past posts...

only problem is i don't use debug mode for the templates (i checked) and i even made the appropriate change just incase and it didn't seem to solve my problem ;P either way excellent hack...

its probably just something 'stupid' ;) anyways could it have anything to do with php version? thanks in advance man... superb work as always :)

g-force2k2

Logician 10-05-2002 07:25 AM

@mikey8270:
Quote:

Originally posted by mikey8270
is there any way to make it show like 'You have relied to this thread' or You have not replied to this thread' somewhere on the showthread page to everybody except guests?
Sorry this can't be done, because at the moment thread is displayed, vbulletin does not save the thread repliers info in a variable. If did, this would be possible.

You have to make an SQL query beforehand, to get if visitor is a thread replier and save the result in a variable. Then you can use this variable in your conditional in this hack to achieve what you wanted..

@g-force2k2:
Quote:

anways i get the infamous 6==6 as stated in the past posts...
I would say your conditional syntax may be wrong.

For example if you wrote it as:
PHP Code:

[[($bbuserinfo[userid]==1)]] TEXT GOES HERE [[($bbuserinfo[userid]==1)]] 

it looks good but it is not. Please notice the closing tag lacks / sign. So it should be:
PHP Code:

[[($bbuserinfo[userid]==1)]] TEXT GOES HERE [[/($bbuserinfo[userid]==1)]] 

If this is not your problem, try to make this change:
find:

PHP Code:

 return "<!-- BEGIN TEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->"

And replace it as:

PHP Code:

 return "<!-- BEGIN TEMPLATE: $templatename -->\n".advanced_templates($template)."\n<!-- END TEMPLATE: $templatename -->"

If this also not fixes it, can you please post here the conditional you used (please copy paste from the template) and also function gettemplate after you applied the hack.. Let me check..

zonegray 10-05-2002 11:26 AM

g-force2k2 - I had the same problem... template debug was turned off, but I still saw the 6==6 stuff, I even added the other hack that Logi mentioned, and that didn't work. Eventually I reviewed the installation with a gun to my head, and finally found the typo.

My mistake was that half the edits went to the wrong server, due to a peculiarity of ssh.com's Secure File Transfer that I used while editing.

Logician 10-05-2002 12:19 PM

Quote:

Originally posted by zonegray
My mistake was that half the edits went to the wrong server, due to a peculiarity of ssh.com's Secure File Transfer that I used while editing.
:)

Babylon 10-07-2002 09:26 AM

Hi Logician :)

Have to say that this hack is amazing! Finally gives me the full flexibility in my templates that I've been looking for! Great work :)

I was reading the previous posts in this thread (particularly the third page) and came up with a slightly different installation alternative which allows people to have the "Add template name in comments" option on, and makes the script slightly more optimised (using the info you said on the third page) and still makes installation only 2 steps :)

(I was very happy when reading through the hack installation details first time round to find there were only 2 installation steps as I was trying to install about 2 hacks at the time :/ )

Back to what I was talking about:

Instead of step one being:

Code:

1- Edit admin/functions.php, find
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
return $template;
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Replace it AS:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
return advanced_templates($template);
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Change step one to:

Code:

1- Edit admin/functions.php, find
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if ($gethtmlcomments and $addtemplatename) {
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Replace it AS:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if (substr_count($template,'[[/(')>=1) {
        $template = advanced_templates($template);
  }
  if ($gethtmlcomments and $addtemplatename) {
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Logician 10-07-2002 09:39 AM

Quote:

Originally posted by Babylon
I was reading the previous posts in this thread (particularly the third page) and came up with a slightly different installation alternative which allows people to have the "Add template name in comments" option on, and makes the script slightly more optimised (using the info you said on the third page) and still makes installation only 2 steps :)

Yes Babylon, your solution is quite good which solves 2 issues in 1 step. ;)

In fact I should have already updated the instructions but I have little time and too many hacks to support nowadays.. Fortunately, hack thread is not yet too long, modification is not so crucial and the users of this hack are usually power-users (like yourself) who can achieve things without my help. :)

Anyway, I will hopefully update them very soon..

Babylon 10-07-2002 06:06 PM

Very true :) Well, again, excellent hack! JUst trying to think of the best things to use it for, but there's just so much i wanna change in my forum now!

This is only my second post ya know! :)

Wildthinks 10-07-2002 06:22 PM

Hi Logician,

i have try insert "Hi $bbuserinfo[username],", but display is that one and not "Hi Wildthinks" or so on... any Hints or impossible?

Martin CX 10-08-2002 12:15 AM

Quote:

Originally posted by Wildthinks
i have try insert "Hi $bbuserinfo[username],", but display is that one and not "Hi Wildthinks" or so on... any Hints or impossible?
This hasn't really anything to do with the hack (or has it?) but use $username if you want to display the users username.

Logician 10-08-2002 10:15 AM

Quote:

Originally posted by Wildthinks
Hi Logician,

i have try insert "Hi $bbuserinfo[username],", but display is that one and not "Hi Wildthinks" or so on... any Hints or impossible?

It should and I tested it and it does here..

Can you give more info? What was your exact conditional and in which template did you use it?

Devil-GOD 10-08-2002 11:42 AM

great
***install***

Wildthinks 10-09-2002 08:19 AM

Quote:

Originally posted by Logician

It should and I tested it and it does here..

Can you give more info? What was your exact conditional and in which template did you use it?

sorry wrong thread... the problem is in the announcement script ...
i wrote there ... Sorry...

Colon33 10-13-2002 02:59 AM

I run vb 2.2.6 right now, and was always afraid to update to 2.2.7 and then to 2.2.8 because many people said there templates messed up and hacks messed up... is it safe to upgrade a board that has alot of template changes and runs a whole RPG setup complete with itemshop and everything? Cause i really want to install this hack to add more atmosphere to an already interactive board.

Logician 10-13-2002 08:43 AM

Quote:

Originally posted by Colon33
I run vb 2.2.6 right now, and was always afraid to update to 2.2.7 and then to 2.2.8 because many people said there templates messed up and hacks messed up... is it safe to upgrade a board that has alot of template changes and runs a whole RPG setup complete with itemshop and everything? Cause i really want to install this hack to add more atmosphere to an already interactive board.
Colon33, upgrading the board does not mess the templates but if you have hacks applied you'll lose them and need to reapply. So it may be a problem for you if you have a lot of hacks.

But the good news is this hack does not require 2.2.8 to work. I think I mentioned in the first message of the thread as well: It works with all vb versions. I coded it in 2.2.6 and my board is still 2.2.6 and it has no problems.. ;)

So go ahead and install it..

Dean C 10-14-2002 06:20 PM

whats the conditional for forumid?

Regards

- miSt

Logician 10-15-2002 09:53 AM

Quote:

Originally posted by Mist
whats the conditional for forumid?

It may change according to the template you are applying but usually $forumid will do the trick. You can check the template code (or script code that calls that template) to see if another variable is used or not (like $threadinfo[forumid])

Dean C 10-15-2002 03:39 PM

ill do it forumdisplay .

so what will be the conditional code i can use in the template

i.e. the one in " [ "'s

- mISt

Logician 10-16-2002 09:17 AM

Quote:

Originally posted by Mist
ill do it forumdisplay .

so what will be the conditional code i can use in the template

i.e. the one in " [ "'s

- mISt

($forumid==X)

Dean C 10-16-2002 03:44 PM

so if i put this in my forumdisplay template it would only apply to the forum whose id is 2

PHP Code:

[(forumid==2)]
Test
[/(forumid==2

?

Regards

- miSt

Logician 10-17-2002 11:55 AM

Quote:

Originally posted by Mist
so if i put this in my forumdisplay template it would only apply to the forum whose id is 2

PHP Code:

[(forumid==2)]
Test
[/(forumid==2


Yes it should.. However dont forget the closing ) in the second line..

Dean C 10-17-2002 05:31 PM

hehe oops

Right one more question... can you have a global conditional as well as single conditionals

Cuz im my forumdisplay template i want to have one template for a specific forum and i want the default template to apply for the rest... Im sick of doing this with extra styles and assigning a forum a specific style set as it gets too confusing

I want to use something like this in my forumdisplay template:

PHP Code:

[(forumid==2)]
This will be the template for the forums whose id is 2
[/(forumid==2)]

[(
forumid==Restofforums)]
This will be the template for all other forums that haven't got a conditional assigned to them
[/(forumid==Restofforums)] 

_______

Any ideas?

Regards

- miSt

Logician 10-17-2002 06:03 PM

Quote:

Originally posted by Mist
Cuz im my forumdisplay template i want to have one template for a specific forum and i want the default template to apply for the rest... Im sick of doing this with extra styles and assigning a forum a specific style set as it gets too confusing

What you need is this:

PHP Code:

[[($forumid==2)]]
This will be the template for the forums whose id is 2
[[/($forumid==2)]]
[[(
$forumid!=2)]]
This will be the template for the forums whose id is NOT 2
[[/($forumid!=2)]] 


Dean C 10-18-2002 05:24 PM

lol why didn't i think of the " != "

Thanks buddy

- miSt

HappyPike 10-18-2002 07:50 PM

hey Logician,

Can this hack be use to hide or show certain features such as avatars depending on current server load? If yes, what's the conditionals for that?

Thanks! This is a really useful hack!

Logician 10-18-2002 08:03 PM

Quote:

Originally posted by HappyPike

Can this hack be use to hide or show certain features such as avatars depending on current server load? If yes, what's the conditionals for that?

As it is, no.

But if you can add another hack which will assign the server load (or anything you like) to a global variable (like in global.php) then yes it can. After you assign the variable value, you should edit postbit template and find the avatar variable (was it $post[avatar] ?) and replace it with this code:

PHP Code:

[[($yourvariable<x)]]
$post[avatar]
[[/(
$yourvariable<x)]] 

Now avatars would be displayed only when $yourvariable is less than x.

EDIT: BTW. do not forget that this may not help much since the template modifications is just about the visual design. That is, your db would be still queried for the avatar in this example but just not displayed to the end user inside your template. So it wouldnt help decreasing server load much.. just the bandwidth maybe :)

John 10-19-2002 06:19 PM

Logician - you genius!!

You would not believe the work this hack has saved me, and I installed it in under a minute!

Thanks!

pool-werbung 10-27-2002 07:18 PM

Can i use a condition of the ip of the user? Is there a var that in it is the user-ip?

NTLDR 10-27-2002 07:45 PM

You could try using:

PHP Code:

$HTTP_SERVER_VARS[REMOTE_ADDR

No idea if it will work, or if any of the $HTTP variables will work with this hack without modification. I'm sure Logician can shed some light though ;)

Logician 10-27-2002 10:19 PM

NTDLR's method should work.. The hack is compatible with ALL variables in the memory so if I guess $HTTP_SERVER_VARS[REMOTE_ADDR] will work..

Also vb saves user's IP address in "$ipaddress" variable in global.php, so $ipaddress should work too.

However I'm sure you are well aware that IP address is not a good mainstay for conditionals since many users have dynamic IP.

JakeC 10-29-2002 02:49 AM

Excellent Hack! Now even I can feel like a power user!!

JakeC

Bandit 11-02-2002 02:05 AM

I installed this hack and all of a sudden my forums started to show the default templates for every style I have. The template is still the same (in the user cp), but my forums just show the default one... I tried uploading the old functions.php but it did not fix the problem. Any ideas??


All times are GMT. The time now is 04:20 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.01636 seconds
  • Memory Usage 1,867KB
  • 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
  • (12)bbcode_php_printable
  • (18)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete