vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Rotate styles by day. (https://vborg.vbsupport.ru/showthread.php?t=45949)

Brad 11-21-2002 04:30 AM

Rotate styles by day.
 
Say i have 7 styles made for my forums, they only differ in color. Now say i want style 1 to display on sunday, style 2 on monday etc. Would it be possible to write a script that would automaticly change the default style at 12 midnight everyday?.

Logician 11-21-2002 08:25 AM

There are some issues to be solved like if your style will overwrite forum's forced styles or user's custom style but assuming answers are no for both here is your code:

edit global.php (in forum dir, not in Admin dir!), find:
PHP Code:

// is style in the forum/thread set?
if (isset($codestyleid) and $codestyleid!=0) {
  
$styleid=$codestyleid;
} else {

  
// Will look in the user info for a style
  
if ($bbuserinfo['styleid']!=0) { //style specified
    
$styleid=$bbuserinfo['styleid'];
  } else { 
//no style
    
$styleid=1;
  } 

Replace it as:
PHP Code:

// is style in the forum/thread set?
if (isset($codestyleid) and $codestyleid!=0) {
  
$styleid=$codestyleid;
} else {

  
// Will look in the user info for a style
  
if ($bbuserinfo['styleid']!=0) { //style specified
    
$styleid=$bbuserinfo['styleid'];
  } else { 
//no style
$styleid=date("w",time())+1;
  } 

Now the hack will make these styles default automatically everyday at 12:00 AM (According to the server time!):
Sunday => Style 1
Monday => Style 2
..
..
Saturday => Style 7

Enjoy.. :glasses:

Brad 11-21-2002 10:20 AM

Thanks man, ill make sure to use this when we introduce the new styles next week :)

Brad 11-21-2002 10:23 AM

Last question, seeing how the code is style 1 (sunday) would be named '0' correct?

Logician 11-21-2002 11:10 AM

I didn't get the question

Brad 11-21-2002 11:43 AM

Well seeing out its using the date function i looked it up, heres the quote of what i read:

Quote:

w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
but now i see a +1 in your code.

Heres the question, what would the name of the styles be? 1, or style 1? Im not clear on how it works. Again thanks for all your help

Logician 11-21-2002 12:18 PM

style name does not matter. You can name styles in anyway you like.

My code is interested in style ids, not names. So it will display styleid 1 in sunday and 2 in monday etc.

If your styles are not in order, instead of $styleid=date("w",time())+1;
you can use this code:

if (date("w",time())==0)
{
$styleid=X; //enter id for sunday
}
elseif (date("w",time())==1)
{
$styleid=Y;
//enter id for monday
}
..
..
elseif (date("w",time())==6)
{
$styleid=Q;
//enter id for saturday
}

see? ;)

Brad 11-21-2002 12:28 PM

Yea, i relized it was id based when i was on my way to breakfast, thanks again :)


All times are GMT. The time now is 10:03 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.01015 seconds
  • Memory Usage 1,734KB
  • 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_php_printable
  • (1)bbcode_quote_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