vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   php date (https://vborg.vbsupport.ru/showthread.php?t=246442)

philwareham 07-13-2010 07:28 AM

php date
 
Hi there,
I'm integrating vBulletin into some of my existing site templates - how can I replicate the following simple php code within a vBulletin template (header), as I can't use raw php in a template can I?

Code:

<?php echo date('m'); ?>
Any help most welcome.
Phil

Floris 07-13-2010 08:06 AM

make a new plugin for the header and do something like

$mydate = vbdate();

and in your template <div>$mydate</div>

check the API for the syntax for vbdate()

If the vb4 template echoing out is different, i wouldn't know. never bothered to look at it. I remember though it might be like <vb:raw $mydate> or something.

philwareham 07-13-2010 10:12 AM

Thanks, following your suggestions this seems to work:

Made a new global_start plugin as so:

Code:

$mymonth = vbdate('m');
vB_Template::preRegister('header',array('cssdate' => $mymonth));

Then, in my (vb4) header template use the following hook:

Code:

{vb:raw mymonth}
Which gives a numerical month output which is exactly what I wanted (so it's '07' for July). Obviously the 'm' can be changed to other date formats depending on what use you want from it.

Phil


All times are GMT. The time now is 11:52 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.01125 seconds
  • Memory Usage 1,708KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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