Phoca Extensions
Free extensions for Joomla! CMS

Displaying Google AdSense in detail window of Phoca Gallery

Category: Phoca Gallery Improvements

 

This article describes how to change Phoca Gallery component so the Google Adsense Code will be displayed in detail window below the image.

First install Phoca - Google AdSense Easy module ( How to install it ) . Get Google AdSense Code from your Google AdSense Acount and paste it into the AdSense field in module settings ( see documentation ). Type phocaads into the position field, publish the module and save it.

Now open the Phoca Gallery php file in your text editor:

components/com_phocagallery/views/detail/view.html.php and paste the following code:

// PHOCA ADS EDIT - - - - - - - - - -
$adsRenderer	= $document->loadRenderer('module');
$adsOutput		= '';
$adsPosition	= JModuleHelper::getModules('phocaads');

if (isset($adsPosition[0])) {
	$paramsM	= new JParameter( $adsPosition[0]->params );
	if (isset($adsPosition[0]->module) && $adsPosition[0]->module =='mod_phoca_google_adsense' && isset($adsPosition[0]->params)) {
		$adsense_code		= $paramsM->get( 'adsense_code','');
		$ip_block_list		= $paramsM->get( 'ip_block_list','');
		$alternate_content	= $paramsM->get( 'alternate_content','');
		$module_css_style	= $paramsM->get( 'module_css_style','');
		$ip_array			= explode( ';', $ip_block_list );
		$ipa				= 1;//display
		
		foreach ($ip_array as $value){
			if ($_SERVER["REMOTE_ADDR"] == trim($value)) {
				$ipa = 0;
			}
		}
		if ($module_css_style) {
			$adsOutput .= '<div style="'.$module_css_style.'">';
		}
		if ($ipa == 1){
			$adsOutput .=  $adsense_code;
		} else {
			$adsOutput .=  $alternate_content;
		}
		if ($module_css_style) {
			$adsOutput .=  '</div>';
		}
	}
}
$this->assignRef( 'adsoutput', $adsOutput );
// PHOCA ADS EDIT - - - - - - - - - -

into the line + - 26 (after $params = &$mainframe->getParams(); , copy the code without php start and end tags).

Save the modified file and open next Phoca Gallery php file:

components/com_phocagallery/views/detail/tmpl/default.php and paste the following code:

<?php echo $this->adsoutput; ?>

into the line + - 42 (before if ($this->tmpl['detailbuttons'] == 1){), so Google AdSense will be displayed below the image (copy the code without first php start tag and last  php end tag).

In case there is no place for displaying Google AdSense in the detail window, just resize the window in Paramters Component (in menu link to Phoca Gallery).

 

 

 

Phoca Forum - Latest Topics