glFusion Wiki

Site Tools


glfusion:development:custom

lib-custom.php

lib-custom.php provides a method for you to replace or augment certain glFusion functionality. If you have experience writing PHP code, lib-custom.php gives you several hooks into glFusion's functionality.

CUSTOM_displayAdBlock()

Allows you to hook into the PLG_displayAdBlock() function which is supported by:

  • articles
  • forum
  • media gallery
function CUSTOM_displayAdBlock($type, $counter)
{
    global $_CONF;
 
    static $onlyOne = 0;
 
    $retval = '';
    $html = '<img src="'.$_CONF['site_url'].'/images/testbannerad.png">';
 
    switch ( $type ) {
        case 'header' :
            // no ad for header
            break;
        case 'footer' :
            $retval = $html;
            break;
        case 'article' :
            if ( ($counter % 2) == 0 ) {
                $retval =  $html;
            }
            break;
        case 'forum_category_list' :
            if ( ($counter % 2) == 0 ) {
                $retval = $html;
            }
            break;
        case 'forum_topic_list' :
            if ( ($counter % 10) == 0 ) {
                $retval = $html;
            }
            break;
        case 'mediagallery_album_list' :
            if ( ( $counter % 3 ) == 0 ) {
                $retval = $html;
            }
            break;
        case 'mediagallery_media_list' :
            if ( ( $counter % 4 ) == 0 ) {
                if ( $onlyOne == 0 ) {
                    $retval = '<img class="uk-vertical-align-middle" src="'.$_CONF['site_url'].'/images/ad-sample-250x250.gif">';
                }
                $onlyOne++;
            }
            break;
        default :
            break;
    }
    return $retval;
}

FIXME - need to detail all CUSOTM_ hooks

glfusion/development/custom.txt · Last modified: 2017/09/27 16:06 (external edit)