vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   use of php in header template (https://vborg.vbsupport.ru/showthread.php?t=157230)

kjhkjh 09-07-2007 04:58 AM

use of php in header template
 
any help appreciated.

I've got a chunk of php code that looks up values from a table on the db and displays a banner image based on the forum that the code is being shown on. (in the table there are entries for image src, banner link, image alt text, image title text)

I have got this code to work on a new php page that I uploaded to the server (well I got the displaying of a banner from the table - but at this point I didn't have the conditionals of which forum, because it was a php file separate to the forum.)


When I paste this code (and try different edits) into the 'header' template the banners aren't appearing and not only that but often when I make the changes in the header template inside the admincp, i'm told:

Quote:

The following error occurred when attempting to evaluate this template:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/domain1/public_html/domain2/forums/includes/adminfunctions_template.php(3596) : eval()'d code on line 29

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
I can't figure out whats wrong but only have limited php knowledge.

When I edit the header template with conditionals and simple html links, titles, alts etc, then it works. And different forums show me different banners.

But I really need each of the
image url
image hyperlink
image alt text
image title text
...to be variables sourced from a mysql table that I have created


Can anyone help me with this?

I think that it is because the 'header template' doesn't like to deal with external php code in there.

Is there a way that I can make this work?

Thanks in advance

Marco van Herwaarden 09-07-2007 07:51 AM

Templates are HTML and you can not use PHP code in them.

Create a plugin with your PHP code and asign the output to a variable that can be used in your template.

kjhkjh 09-07-2007 11:17 AM

Thanks Marco.

Can you point me in the direction of how to make a plugin?

(I can't seem to find any thread about it. Is it easy to do? I have all my php ready and what you said above seems easy... just no idea where to start :))

http://www.vbulletin.com/docs/html/m..._externalfiles

I think I can figure it out from here - does look pretty easy :)


All times are GMT. The time now is 05:27 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.04398 seconds
  • Memory Usage 1,718KB
  • 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_quote_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