vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   default templates... (https://vborg.vbsupport.ru/showthread.php?t=18516)

chrispadfield 05-28-2001 09:09 PM

Where is the code that determines where the template will be used if a particular styleset does not have a template associated with it? I would like it so that the logic worked like this, i have 2 style sets.

If using style set A

if template - use it
if not template (ie not a custom one in styleset A) then use the default template that comes with VB.

If using style set B

if template use it
if no template, then use the template in style set A. If no template in styleset A then use default template.

See what i mean? This means that for template sets which only have a different header, footer and something else, i do not have to keep up to date every other single template from my default one.

any ideas?

Mas*Mind 05-28-2001 09:16 PM

Correct me if I'm wrong, but do you mean you wanna implement multi-level inheritence?

chrispadfield 05-28-2001 09:20 PM

yes that is exactly what i want.

Mas*Mind 05-28-2001 09:23 PM

Could be implemented, but probably will add alot of mysql-queries.

The problem is you can't predict which templates you have to select from the database on forehand. Mysql doesn't support recursive queries so you'd have to get a workaround on it which will add more queries.

chrispadfield 05-28-2001 09:27 PM

how does it do it now? if there is no template in a specific style? does it then go off and get the template from another style?

i thought an if elseif routine would just add 1 extra query per page which i can cope with but perhaps it is more than that. annoying.

Mas*Mind 05-28-2001 09:31 PM

right now 2 template-sets are selected on forehand: The default template set (with default I mean the one you can't edit, the one with id -1) and the users template-set.

If a template from the users-set doesn't exists he gets the one from the default set.

chrispadfield 05-28-2001 09:37 PM

For my purpose the system would always be

Default -> A -> B/C/D/E/F

as A is my "default" set.

So i guess my options are:

i) using phpmyadmin (or i think there is a variable that allows you to override deleting the real default set, there was with the beta anyway) and over ride the actual default set with my set A templates. Problem is of course upgrading when template changes are made.

ii) somehow load 3 template sets instead of 2 and then change the bit that goes if x, use x elseif use x from template -1.

any idea where these bits of code are? i assume global.php - of to look.

Mas*Mind 05-28-2001 09:43 PM

With your solution you'll limit it to a certain level. The best solution would be to have no limit at all, so you can inherit many levels deep. I thought about it and I think it can be implemented without adding extra queries, but I haven't really figured out how.

The particular code is the cachetemplates function in admin/functions.php

chrispadfield 05-28-2001 09:47 PM

i think this is the section:

PHP Code:

function cachetemplates($templateslist) {
  
// $templateslist: comma delimited list
  
global $templatecache,$DB_site,$templatesetid,$loadmaxusers,$loadbirthdays;

  
// add in sql info
  //$templateslist=str_replace(",","' OR title='",$templateslist);
  
$templateslist=str_replace(','"','"$templateslist);

  
// run query
  
$temps=$DB_site->query("SELECT template,title
                          FROM template
                          WHERE (title IN ('
$templateslist')
                            AND (templatesetid=-1 OR templatesetid='
$templatesetid'))
                          "
.iif ($loadmaxusers,"OR (title = 'maxloggedin')","")."
                          "
.iif ($loadbirthdays,"OR (title = 'birthdays')","")."
                          ORDER BY templatesetid"
);

  
// cache templates
  
while ($temp=$DB_site->fetch_array($temps)) {
    
$templatecache["$temp[title]"]=$temp['template'];
  }
  unset(
$temp);
  
$DB_site->free_result($temps);



how does this OR thing work

(templatesetid=-1 OR templatesetid='$templatesetid'))

does that mean, find a specific template where templatesetid=x as well as where templatesetid=-1? so both are returned. By ordering by templatesetid, the ones with a real template setid come up first?

any ideas what would happen if i just did

(templatesetid=-1 OR templatesetid='$templatesetid' OR tempatesetid='10'))

? if i ensure that all my other template sets have a higher number than 10? (or perhaps a lower number if that is what is needed)?

Mas*Mind 05-28-2001 09:57 PM

That probably would work, only you have to change it to:

(templatesetid=-1 OR tempatesetid='10' OR templatesetid='$templatesetid'))

In that particular order, in order to let the inheritance happen in the right order (lot of orders)

but I'm not 100% sure. There is another disadvantage: The result of the query can be far more bigger now, resulting in a slight(?) slowdown...

chrispadfield 05-28-2001 10:01 PM

not sure how much bigger really, as each page generally uses what, about 20 templates probably not much more than that it is only an extra 20 templates (max) which aint much i would think.

going to try.

Mas*Mind 05-28-2001 10:03 PM

don't forget to change this $gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' AND (templatesetid=-1 OR templatesetid='$templatesetid') ORDER BY templatesetid DESC LIMIT 1"); piece of code in the gettemplate function

chrispadfield 05-28-2001 10:04 PM

thanks so much Mas*Mind for all the help here, that change does work perfectly. No idea what the performance issue would be but either way it works :)

a more powerful inheritance system would be quite useful i think though

Mas*Mind 05-28-2001 10:04 PM

hmm..the order here (templatesetid=-1 OR tempatesetid='10' OR templatesetid='$templatesetid')) doesn't matter btw... The result is allready ordered by templatesetid.

This is fairly important because now when A has to inherit from B the templatesetid of A has to be bigger then the one of B

chrispadfield 05-28-2001 10:06 PM

Quote:

Originally posted by Mas*Mind
don't forget to change this $gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' AND (templatesetid=-1 OR templatesetid='$templatesetid') ORDER BY templatesetid DESC LIMIT 1"); piece of code in the gettemplate function
thank you, i would have forgotten !

Mas*Mind 05-28-2001 10:06 PM

Glad I could help you :) You made me think though...I think it wouldn't be really difficult to implement an unlimited inherit-system.

Just let me think on this matter :)

chrispadfield 05-28-2001 10:08 PM

Quote:

Originally posted by Mas*Mind
hmm..the order here (templatesetid=-1 OR tempatesetid='10' OR templatesetid='$templatesetid')) doesn't matter btw... The result is allready ordered by templatesetid.

This is fairly important because now when A has to inherit from B the templatesetid of A has to be bigger then the one of B

That is what i thought but in my case A = 10 and B = 11 and inheritcane is working from B --> A. ie, i just ditched the header in B and it is using A's header (id = 10).

But as -1 is less than 1 (default set) this is probably correct as the inheritance here is also working "downwards".

Mike Sullivan 05-28-2001 10:09 PM

Actually I think Kier and I (but mostly Kier) have already worked out an infinite depth inheritable system. (just a concept; havent actually coded it)

But we're not talking so nyah! ;) It'll probably end up being more efficient than the current system actually...

(Now, why the heck do I keep clicking "quote" instead of "edit"? Argh!)

chrispadfield 05-28-2001 10:10 PM

cool :)

is what i have done going to cause any considerable performance problems though Ed? or should it be ok? all i did in the end was the extra OR templatesetid = 10 in both queries.

Mike Sullivan 05-28-2001 10:11 PM

No, not a ton of performance overhead. But you will be retrieve more records than necessary.

Mas*Mind 05-28-2001 10:19 PM

Quote:

Originally posted by chrispadfield


That is what i thought but in my case A = 10 and B = 11 and inheritcane is working from B --> A. ie, i just ditched the header in B and it is using A's header (id = 10).

But as -1 is less than 1 (default set) this is probably correct as the inheritance here is also working "downwards".

No, it's exactly how I said it should. B inherits from A, thus the id of B has to be bigger then the one of A :)


All times are GMT. The time now is 01:58 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.01059 seconds
  • Memory Usage 1,773KB
  • 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_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (21)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