There’s been an annoying bug in the PHPfox ad system for years. With PHPfox V4 Neutron, that has been removed as the ads are now done in blocks in AdminCP for the admin created ads. However, for those running PHPfox V3, this annoying bug has ads disappearing unless we clear cache. After having cleared cache several times yesterday, I got fed up so here’s how to make ads in a block and also how to hide them from specific areas.
Make a block
V3 Nebula: AdminCP >> CMS >> Block >> Add New Block
Product: phpfox
Module: user
Title: put a good title so that you will know what this is
Type: PHP Code
Controller: None (sitewide)
Placement: We chose Block 3
Now for the code in the PHP/HTML block put:
1 2 3 4 5 6 7 8 9 10 |
<?php $aNotInTheseModules = array('admincp', 'forum'); $arrayDoNotLoadHere = array('core.index-visitor', 'article.view', 'marketplace.index'); if (in_array(Phpfox::getLib('module')->getFullControllerName(), $arrayDoNotLoadHere) || in_array(Phpfox::getLib('module')->getModuleName(), $aNotInTheseModules)) { return false; } echo '<div class="block" ><img src="yourimage url" alt="youralttitle"><b><a href="url for your ad" target ="_blank">Title to show</a></b><p>additional description to show</p> </div>'; ?> |
The above is an example of how to do the ad. An explanation:
If you want to hide the ad from entire modules of the site like we did, just add or remove from our first line of code “aNotInTheseModules” anything you need to like our examples. Where you see we have added ‘admincp’, ‘forum’ that is telling the script not to show this ad in the admincp and in the entire forum modules.
If you want to hide the ad from pages of the site (maybe core.index-visitor which is the visitor home page, you see the second line “arrayDoNotLoadHere”. Just add the specific pages of the site you don’t want to show this on. The controller can be seen in the block controller list if you are not sure.
OR
V4 Neutron: AdminCP >> Blocks and click Add Block
Title: put a good title so that you will know what this is
Type: PHP Code
Controller: None (sitewide)
Placement: We chose Block 3
PHP/HTML code:
1 2 3 4 |
<div class="block""> <img src="your image source" alt="your alt description"><b><a href="your ad url" target ="_blank">Title to show</a></b> <p>Another descriptive paragraph</p> </div> |
Note the above for V4 does not have a way to hide it from various places on the site as we can’t get that to work yet. V4 has some changes to it and this appears to be one of them. If you don’t want it to show all over, for now you’ll want to just manually make the block where you want it which will be a bit of work to do.