Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2013, 07:18 AM
VHLinks VHLinks is offline
 
Join Date: Jan 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Getting simple php code to show in sidebar

Hi guys,

Been pulling my hair out trying to get my banner code to work in the sidebar.

Any ideas how to make this code work? I've tried everything, seems like it should be very easy.

<?php
include_once('scripts/125_adverts.php');
echo "<div align='center'>$bannerAd</div>";
?>

Thanks!
Reply With Quote
  #2  
Old 10-29-2013, 10:11 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's the code in the file, scripts/125_adverts.php
Reply With Quote
  #3  
Old 10-29-2013, 02:39 PM
VHLinks VHLinks is offline
 
Join Date: Jan 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok it's long...

Code:
<?php

$bannerCounter= 1; 



$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/CTGY/CF\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/CTGY:CF.jpg\" BORDER=\"0\" HEIGHT=\"402\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;



$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/CTGY/shirts_kids\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/CTGY:shirts_kids_ANOTHER.jpg\" BORDER=\"0\" HEIGHT=\"390\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;






$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/CTGY/shirts_kids\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/CTGY:shirts_kids.jpg\" BORDER=\"0\" HEIGHT=\"329\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;



$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/PROD/ACC05\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:ACC05.jpg\" BORDER=\"0\" HEIGHT=\"236\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;



$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/EVHA05\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:EVHA05.jpg\" BORDER=\"0\" HEIGHT=\"240\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;



$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S91\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S91.jpg\" BORDER=\"0\" HEIGHT=\"387\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;




$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S164\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S164.jpg\" BORDER=\"0\" HEIGHT=\"265\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;


$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S179\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S179.jpg\" BORDER=\"0\" HEIGHT=\"253\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;


$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S216\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S216.jpg\" BORDER=\"0\" HEIGHT=\"263\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;


$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S311\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S311.jpg\" BORDER=\"0\" HEIGHT=\"256\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;


$bannerCode[$bannerCounter] = "<A HREF=\"http://www.vanhalenstore.com/page/VH/PROD/S312\" target=\"_blank\">

<IMG SRC=\"/adimages/6-2013/PROD:S312.jpg\" BORDER=\"0\" HEIGHT=\"342\" WIDTH=\"160\" alt=\"VanHalenStore.com\"></A>";

$bannerCounter++;








$bannerAdTotals = $bannerCounter - 1;

if($bannerAdTotals>1)

{

   mt_srand((double)microtime() * 1234567);

   $bannerPicked = mt_rand(1, $bannerAdTotals);

}

else

{

   $bannerPicked = 1;

}

$bannerAd = $bannerCode[$bannerPicked];

?>
Reply With Quote
  #4  
Old 10-31-2013, 06:10 AM
VHLinks VHLinks is offline
 
Join Date: Jan 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shoot nobody has any ideas? This is so frustrating, and I know it has to be easy.
Reply With Quote
  #5  
Old 10-31-2013, 10:50 AM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you have a template created for the sidebar block?

Also, you must return your value for $bannerAd, not just set it.

I'd suggest looking at a couple of mods that include a sidebar block for more detailed examples.
Reply With Quote
Благодарность от:
Max Taxable
  #6  
Old 10-31-2013, 03:18 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually he wouldn't be able to return it as none of the code in the php file is in a function, so he's using it correctly as is.

Which hook are you using to execute that code?
Reply With Quote
  #7  
Old 10-31-2013, 08:47 PM
VHLinks VHLinks is offline
 
Join Date: Jan 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not using any hook to run it right now. I'm upgrading from my 3.8 board, so it's way different. Right now I just call my site's header and left column stuff with a separate .php page and I put that code inside there and it works great. Obviously 4.2.2 is WAY different, so just not sure where to begin to get it in the sidebar.
Reply With Quote
  #8  
Old 10-31-2013, 09:53 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
Actually he wouldn't be able to return it as none of the code in the php file is in a function, so he's using it correctly as is.

Which hook are you using to execute that code?
If he's using the Forum Blocks Manager, PHP code is automatically run as a function...

Attached Images
File Type: jpg content.jpg (146.9 KB, 0 views)
Reply With Quote
  #9  
Old 10-31-2013, 11:59 PM
VHLinks VHLinks is offline
 
Join Date: Jan 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
If he's using the Forum Blocks Manager, PHP code is automatically run as a function...

Which is what I tried to do and it just won't parse anything.
Reply With Quote
  #10  
Old 11-01-2013, 12:28 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by VHLinks View Post
Which is what I tried to do and it just won't parse anything.
Download my raffle mod...

https://vborg.vbsupport.ru/showthrea...hlight=raffles

Install it and look at the raffle_sideblock template. And look at the 'Active Raffles' block code for an example of how to return data to the sideblock template. (that is what is shown in the picture above)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:15 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.05815 seconds
  • Memory Usage 2,280KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete