1
jmc286642
Multiple <{$xoops_banner}>?
  • 2005/1/18 4:03

  • jmc286642

  • Just popping in

  • Posts: 1

  • Since: 2005/1/18


Is there a way to declare multiple <{$xoops_banner}> elements in theme.html and have XOOPS bring up two different banners? Perhaps with some creative Smarty loops?

Example markup:

<td>
  <{
$xoops_banner}>
  <
br/>
  <{
$xoops_banner}>
td>


Declaring <{$xoops_banner}> twice as in the example above merely causes XOOPS to bring up two instances of the same banner ad.

2
Mithrandir
Re: Multiple ?

As you have discovered, a Smarty variable points to the same value no matter how many times you place it in your theme.

You will have to edit the xoops_getbanner() function in include/functions.php to return an array of banners which you will then be able to use with <{$xoops_banner.0}>, <{$xoops_banner.1}> etc. depending on how you build the array in the function.

3
Liawlius
Solution
  • 2005/4/29 18:48

  • Liawlius

  • Just popping in

  • Posts: 4

  • Since: 2005/4/29


I solved this problem like this:

function xoops_getbanner()
{
    global 
$xoopsConfig;
    
$db =& Database::getInstance();
    
$bresult $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner"));
    list (
$numrows) = $db->fetchRow($bresult);
    while (
$numrows <> 0) {
    
$numrows $numrows 1;
    
$bannum $numrows;
        
$bresult $db->query("SELECT * FROM ".$db->prefix("banner"), 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$datetime());
            
$db->queryF($sql);
            
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u"$db->prefix("banner"), $bid));
        }
        if (
$htmlbanner){
            
$bannerobject $htmlcode;
        } else{
            
$bannerobject '
.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" target="_blank">';
            if (
stristr($imageurl'.swf')) {
                
$bannerobject $bannerobject
                    
.''
                    
.'.$imageurl.'">'
                    
.''
                    
.'.$imageurl.'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"; type="application/x-shockwave-flash" width="468" height="60">'
                    
.''
                    
.'';
            } else {
                
$bannerobject $bannerobject.'.$imageurl.'" alt="" />';
            }

            
$bannerobject $bannerobject.'
'
;
        }
     
$banner_ret $banner_ret.'
'
.$bannerobject;
    
}
        return 
$banner_ret;

}


Now this function repeats banner adding routine until no more banners left. If you can suggest better solution dont be shy

4
Liawlius
Re: Multiple ?
  • 2005/4/29 18:49

  • Liawlius

  • Just popping in

  • Posts: 4

  • Since: 2005/4/29


My solution:

function xoops_getbanner()
{
    global 
$xoopsConfig;
    
$db =& Database::getInstance();
    
$bresult $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner"));
    list (
$numrows) = $db->fetchRow($bresult);
    while (
$numrows <> 0) {
    
$numrows $numrows 1;
    
$bannum $numrows;
        
$bresult $db->query("SELECT * FROM ".$db->prefix("banner"), 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$datetime());
            
$db->queryF($sql);
            
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u"$db->prefix("banner"), $bid));
        }
        if (
$htmlbanner){
            
$bannerobject $htmlcode;
        } else{
            
$bannerobject '
.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" target="_blank">';
            if (
stristr($imageurl'.swf')) {
                
$bannerobject $bannerobject
                    
.''
                    
.'.$imageurl.'">'
                    
.''
                    
.'.$imageurl.'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"; type="application/x-shockwave-flash" width="468" height="60">'
                    
.''
                    
.'';
            } else {
                
$bannerobject $bannerobject.'.$imageurl.'" alt="" />';
            }

            
$bannerobject $bannerobject.'
'
;
        }
     
$banner_ret $banner_ret.'
'
.$bannerobject;
    
}
        return 
$banner_ret;

}


Its loop whitch repeats banner adding routine untill no more banner left to add.

----
I edited this post and the previous one to use the [ code ] tag - Dave_L

5
Anonymous
Re: Multiple <{$xoops_banner}>?
  • 2005/5/10 20:09

  • Anonymous

  • Posts: 0

  • Since:


Hi,

Is possible now to use more than banner in many blocks, example : <{$xoops_banner1}>,<{$xoops_banner2}>, .. etc ?


Login

Who's Online

810 user(s) are online (62 user(s) are browsing Support Forums)


Members: 0


Guests: 810


more...

Donat-O-Meter

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

Latest GitHub Commits