Customblock - Changing banner?

Post Reply

Topic author
Jens E
Active Member
Posts: 4
Joined: 31. December 2008 14:48

Customblock - Changing banner?

Post by Jens E »

I wannted to have a banner in one of the custom block that should change everytime the page was reloaded. I found a nice php script that would do this for me but i have problem loading the script from the custom block. I first tried with a script that changed picture everytime and that worked fine when using

Code: Select all

[img]http://blabla.com/banners/script.php[/img9
. But when installing the one that changed banner AND made it a clickable link i didnt work anymore. Anyone who has an idea how i should make it work?

The script i am using is returning html code with "echo"..

Jens
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Customblock - Changing banner?

Post by Kevin »

That would be best reached with a "complete" custom block.
Means a included PHP file and a included template file.

Show me the PHP and HTML code you want to use.

Moved to block request.
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!

Topic author
Jens E
Active Member
Posts: 4
Joined: 31. December 2008 14:48

Re: Customblock - Changing banner?

Post by Jens E »

This is the php script i want to use:

Code: Select all

<?php

/*****
Random Banners

(C) 2007 NZ's Finest
www.nzsfinest.com

HOW TO USE -
1. Edit the information below (http://www.website.com,image.png, etc).
The format is <url>,<image>

2. Or add in new banners by copying the text
"http://www.website.com,image.png",
and pasting it on a new line above
"http://www.website.com,image.png",

Then include it on your website by using the code:
include("banners.php");
*****/

$banners = array(
"http://www.ojzoo.com,http://www.loricariidae.se/banners/ojzoo.jpg",
"http://www.cyberzoo.com,http://www.loricariidae.se/banners/cyberzoo.jpg"
);

/*****
ATTENTION -
Do not edit below this line unless you know what you are doing.
*****/

$randnum = rand(0, count($banners) - 1); // Choose a random banner
$exploded = explode(",", $banners[$randnum]); // Separate chosen banner by ,

$url = $exploded[0]; // Grab the URL for the banner
$img = $exploded[1]; // Grab the image for the banner

// Display the banner
echo "<a href=\"$url\">";
echo "<img src=\"$img\" border=\"0\" />";
echo "</a>";

?>
Its an really easy and basic "random banner" script that i want to include in a custom block OR some other sort of block..
The banner is the only thing that should be displayed in the block, no text or anything..

Thanx for help!

Jens
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Customblock - Changing banner?

Post by Kevin »

Create a new file, called banner.php save it in portal/block/ - content:

Code: Select all

<?php

/**
*
* @package - Board3portal
* @copyright (c) kevin / saint ( www.board3.de/ ), (c) Ice, (c) nickvergessen ( www.flying-bits.org/ ), (c) redbull254 ( www.digitalfotografie-foren.de ), (c) Christian_N ( www.phpbb-projekt.de )
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

if (!defined('IN_PHPBB'))
{
   exit;
}

if (!defined('IN_PORTAL'))
{
   exit;
}

$banners = array(
"http://www.ojzoo.com,http://www.loricariidae.se/banners/ojzoo.jpg",
"http://www.cyberzoo.com,http://www.loricariidae.se/banners/cyberzoo.jpg"
);

/*****
ATTENTION -
Do not edit below this line unless you know what you are doing.
*****/

$randnum = rand(0, count($banners) - 1); // Choose a random banner
$exploded = explode(",", $banners[$randnum]); // Separate chosen banner by ,

$url = $exploded[0]; // Grab the URL for the banner
$img = $exploded[1]; // Grab the image for the banner

        $template->assign_vars(array(
            'BANNER_URL'     => $url,
            'BANNER_IMAGE'   => $img,
        ));

?>
Include it in your portal.php with:

Code: Select all

include($phpbb_root_path . 'portal/block/banner.'.$phpEx); 
Create a new template file in styles\prosilver\template\portal\block\, called banner.html and use the new variables:
{BANNER_URL}
and
{BANNER_IMAGE}
and include the new template in your portal_body.html

That should be it.
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Customblock - Changing banner?

Post by Kevin »

Why do you sent me a PM?
For your Question i need more information - which style do you use and should it be a site block or a center block?
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!

Topic author
Jens E
Active Member
Posts: 4
Joined: 31. December 2008 14:48

Re: Customblock - Changing banner?

Post by Jens E »

Kevin wrote:Why do you sent me a PM?
For your Question i need more information - which style do you use and should it be a site block or a center block?
I am using the nexus style and i want it to be in centerblock.

Jens
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Customblock - Changing banner?

Post by Kevin »

Show me the wordgraph template content, please.
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!

Topic author
Jens E
Active Member
Posts: 4
Joined: 31. December 2008 14:48

Re: Customblock - Changing banner?

Post by Jens E »

Ah, thanx alot for the help Kevin.. i figured out how to make it work.. :)

www.loricariidae.se

Its in the banner block on the portal page right nu!

Jens - Who is very happy!
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Customblock - Changing banner?

Post by Kevin »

Great - have fun! :)
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!

amroth
Valued Contributor
Posts: 59
Joined: 18. July 2008 19:10

Re: Customblock - Changing banner?

Post by amroth »

und das ganze nun in deutsch ?

Mike hat mich von dem Forum viewtopic.php?f=8&t=1514 hier her verwiesen
www.religions-of-azeroth.de
< Wir Suchen GM's | Scripter / Bugfixxer | Foren Moderatoren | Foren Designer >
Post Reply

Return to “Modification Requests”