Last active
November 18, 2019 13:21
-
-
Save jreviews/4e20eee23fb0b258eae389064d998bd7 to your computer and use it in GitHub Desktop.
JReviews Developer Filter: Hide detail page map when street address is missing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('MVC_FRAMEWORK') or die; | |
/** | |
* Hide map in detail page when the listing doesn't have a street address | |
*/ | |
function hide_map_noaddress($viewVars, $params) | |
{ | |
$controller = $params['controller']; | |
$listing = $viewVars['listing']; | |
$hasAddress = !empty($listing['Field']['pairs']['jr_address']['text'][0]); | |
if ( $controller == 'com_content' && !$hasAddress ) | |
{ | |
$viewVars['show_map'] = false; | |
} | |
return $viewVars; | |
} | |
Clickfwd\Hook\Filter::add('before_theme_render_viewvars', 'hide_map_noaddress', 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this filter:
require_once "hide_map_noaddress.php";