Google ads in Phoca Display box
Posted: 14 Jul 2014, 21:46
Hello,
I am trying to get Google ads to show up in the Phoca display box for gallery images. Thus, when someone goes into a gallery, clicks an image, a google ad would disply in that image box that displays the image content.
I have read your tutorial on how to do this here:
https://www.phoca.cz/documents/45-phoca- ... ca-gallery
However, I am having issues with this. The tutorial gives this example of 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 - - - - - - - - - -
It says to paste this code after $params = &$mainframe->getParams(); inside the components/com_phocagallery/views/detail/view.html.php file. However, after searching throughout this file, I see no such code to paste the above code after. Also, when trying to paste the above code inside the php file I am getting a syntax error. I know it says to post the code without php start and end tags but I do not believe there are any start and end tags in the above code. Can you please paste me exactly what I am supposed to paste inside the php file?
Any help would be greatly appreciated. I really need to integrate google ads within gallery and hope to use phoca.
I am trying to get Google ads to show up in the Phoca display box for gallery images. Thus, when someone goes into a gallery, clicks an image, a google ad would disply in that image box that displays the image content.
I have read your tutorial on how to do this here:
https://www.phoca.cz/documents/45-phoca- ... ca-gallery
However, I am having issues with this. The tutorial gives this example of 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 - - - - - - - - - -
It says to paste this code after $params = &$mainframe->getParams(); inside the components/com_phocagallery/views/detail/view.html.php file. However, after searching throughout this file, I see no such code to paste the above code after. Also, when trying to paste the above code inside the php file I am getting a syntax error. I know it says to post the code without php start and end tags but I do not believe there are any start and end tags in the above code. Can you please paste me exactly what I am supposed to paste inside the php file?
Any help would be greatly appreciated. I really need to integrate google ads within gallery and hope to use phoca.