1
codefantom
Banners won't display, PHP won't work in Blocks
  • 2013/6/30 18:28

  • codefantom

  • Just popping in

  • Posts: 19

  • Since: 2013/6/19


First, I created by own banner. It was 500x200 originally but after Googling I changed it to 468x20. There was a posting that said this was the limit of the size banners xoops would accept. Can someone confirm that for me please?

Next I tried to get the banner to display but no results. I don't even know where it's suppose to display at. But the funny things it that the banner admin section is applying expressions even without seeing the banner.

Next I tried blocks. I found a posting for "Revolution Banner System" and so I pasted the appropriate code within the function.php within the root_directory/include/

function getbanner_from_id_banner($banner_id) { ###### Hack by www.stefanosilvestrini.com ###### global $xoopsConfig; $db =& Database::getInstance(); $bresult = $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner")." WHERE bid = ". $banner_id); list ($numrows) = $db->fetchRow($bresult); if ( $numrows > 1 ) { $numrows = $numrows-1; mt_srand((double)microtime()*1000000); $bannum = mt_rand(0, $numrows); } else { $bannum = 0; } if ( $numrows > 0 ) { $bresult = $db->query("SELECT * FROM ".$db->prefix("banner")." WHERE bid = ". $banner_id, 1, $bannum); list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { // EMPTY } else { $db->queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db->prefix("banner"), $bid)); } /* Check if this impression is the last one and print the banner */ if ( $imptotal == $impmade ) { $newid = $db->genId($db->prefix("bannerfinish")."_bid_seq"); $sql = sprintf("INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)", $db->prefix("bannerfinish"), $newid, $cid, $impmade, $clicks, $date, time()); $db->queryF($sql); $db->queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db->prefix("banner"), $bid)); } if ($htmlbanner){ $bannerobject = $htmlcode; }else{ $bannerobject = ''; if (stristr($imageurl, '.swf')) { $bannerobject = $bannerobject .'' .'' .'' .'' .'' .''; } else { $bannerobject = $bannerobject.''; }  $bannerobject = $bannerobject.'
'; } return $bannerobject; } }  function getbanner_from_id_client($client_id) { ###### Hack by www.stefanosilvestrini.com ###### global $xoopsConfig; $db =& Database::getInstance(); $bresult = $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner")." WHERE cid = ". $client_id); list ($numrows) = $db->fetchRow($bresult); if ( $numrows > 1 ) { $numrows = $numrows-1; mt_srand((double)microtime()*1000000); $bannum = mt_rand(0, $numrows); } else { $bannum = 0; } if ( $numrows > 0 ) { $bresult = $db->query("SELECT * FROM ".$db->prefix("banner")." WHERE cid = ". $client_id ." ORDER BY rand()", 1, $bannum); list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { // EMPTY } else { $db->queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db->prefix("banner"), $bid)); } /* Check if this impression is the last one and print the banner */ if ( $imptotal == $impmade ) { $newid = $db->genId($db->prefix("bannerfinish")."_bid_seq"); $sql = sprintf("INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)", $db->prefix("bannerfinish"), $newid, $cid, $impmade, $clicks, $date, time()); $db->queryF($sql); $db->queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db->prefix("banner"), $bid)); } if ($htmlbanner){ $bannerobject = $htmlcode; }else{ $bannerobject = ''; if (stristr($imageurl, '.swf')) { $bannerobject = $bannerobject .'' .'' .'' .'' .'' .''; } else { $bannerobject = $bannerobject.''; }  $bannerobject = $bannerobject.'
'; } return $bannerobject; } }


Now from this I am suppose to be able to post any of the below php code in the block to get the banner to show:

any random banner
echo xoops_getbanner();

based on banner ID
echo getbanner_from_id_banner(ID_BANNER);

a random client banner, based on client ID
echo getbanner_from_id_client(ID_CLIENT);


And I found 2 more:
echo
echo ""; echo ""; echo xoops_getbanner(); echo ""; echo "";

IF/ESLE
global $xoopsConfig; if ($xoopsConfig['banners'] == 1) {     //Display Banner     echo (xoops_getbanner()); } else {     return false; }


The posting Im reading are a little outdated from the current Xoops version. All other posts show and mention being able to select PHP for the block. My version doesn't give me that option.

1. I need help getting the banners to display or a reason why that aren't displaying or a thought as to where they are suppose to display by default.

2. I also need help finding out why php doesn't display in my blocks.

Any help is appreciated.

2
Mamba
Re: Banners won't display, PHP won't work in Blocks
  • 2013/6/30 19:06

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


To really learn about XOOPS Themes and blocks, I highly recommend the "Design for XOOPS" book For banners, you normally add this Smarty in the theme: <{$xoops_banner}> Just check the Zetagenesis theme for an example how to use it. I never used the "Revolution Banner System", so I don't know how it works, and if it still works with the current XOOPS.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
codefantom
Re: Banners won't display, PHP won't work in Blocks

Thanks for the reply and the advice Mamba. I just got the guide and will read over it all day tomorrow.

4
jlm69
Re: Banners won't display, PHP won't work in Blocks
  • 2013/7/1 13:02

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


@ codefantom
You wrote:

Quote:
The posting Im reading are a little outdated from the current Xoops version. All other posts show and mention being able to select PHP for the block. My version doesn't give me that option.

As far as I know Every Version of Xoops has the option to select "Content Type" It should be set to HTML by default. It should be right above "cache lifetime"
Go into Blocks Administration and click on "add block", you should see it.

What version of Xoops are you using?


John

Login

Who's Online

317 user(s) are online (179 user(s) are browsing Support Forums)


Members: 0


Guests: 317


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits