Page 1 of 1

Customblock - Changing banner?

Posted: 31. December 2008 14:51
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

Re: Customblock - Changing banner?

Posted: 31. December 2008 15:03
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.

Re: Customblock - Changing banner?

Posted: 1. January 2009 11:54
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

Re: Customblock - Changing banner?

Posted: 1. January 2009 13:21
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.

Re: Customblock - Changing banner?

Posted: 1. January 2009 14:26
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?

Re: Customblock - Changing banner?

Posted: 1. January 2009 15:19
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

Re: Customblock - Changing banner?

Posted: 1. January 2009 17:45
by Kevin
Show me the wordgraph template content, please.

Re: Customblock - Changing banner?

Posted: 1. January 2009 18:24
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!

Re: Customblock - Changing banner?

Posted: 1. January 2009 21:03
by Kevin
Great - have fun! :)

Re: Customblock - Changing banner?

Posted: 28. January 2009 22:25
by amroth
und das ganze nun in deutsch ?

Mike hat mich von dem Forum viewtopic.php?f=8&t=1514 hier her verwiesen