JReviews logo Docs
Menu
Version

jreviews:listing.bypass-render.joomla

Allows bypassing the default JReviews listing detail page rendering to implement custom output. When filter returns true, JReviews skips its template processing and you must handle the page output yourself.

Filter
System
Since 6.0.0

You need to have a working knowledge of Hooks before you get started.

Fires before rendering listing detail page, allows complete custom output control

Parameters

Name Type Description
$bypassRender bool Whether to bypass default rendering (return true to bypass)
$article object The Joomla article object or WordPress post object

Variations

This dynamic hook fires for each of the following variations. The {:name} placeholder in the hook name is replaced with one of these values:

- `jreviews:listing.bypass-render.joomla` - For Joomla installations - `jreviews:listing.bypass-render.wordpress` - For WordPress installations

For example, to target the - `jreviews:listing.bypass-render.joomla` - For Joomla installations - `jreviews:listing.bypass-render.wordpress` - For WordPress installations variation, you would use:

fwd_add_filter('jreviews:listing.bypass-render.joomla', function($bypassRender, $article)
{
    // Your code here
    
    return $bypassRender;
}, 20, 2);

Boilerplate Code

Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.

fwd_add_filter('jreviews:listing.bypass-render.joomla', function($bypassRender, $article)
{
    // Your code here
    
    return $bypassRender;
}, 20, 2);

The , 20, N after your callback are the hook priority and the number of arguments your callback accepts. By default, a hook passes your callback only its first argument; for a filter, that is the value being filtered, so a simple function($value) { ... } needs nothing extra. If your callback declares more parameters, such as function($value, $listing) { ... }, you must add N (the parameter count, 2 here). Because N is the fourth argument to fwd_add_filter() or fwd_add_action(), you must also pass the priority (20 is the default). Leaving these off when your callback expects extra parameters causes a Too few arguments to function ... fatal error.

Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

Examples

Restrict Listing Detail Visibility to Owner and Certain Groups

Show access denied message for restricted categories unless user is the listing owner or belongs to authorized groups.

Eventy::addFilter('jreviews:listing.bypass-render.joomla', function($bypass, $article)
{
    // Change IDs to restricted category IDs
    $restrictedCatIds = [1, 2, 3];

    // Change IDs to authorized group IDs  
    $authorizedUserGroups = [1, 2, 3];

    $user = fwd_auth()->user();

    $listing = \JReviews\App\Models\Listing::with('user')
        ->where('contentid', $article->id)
        ->first();

    if (!$listing || !in_array($listing->cat_id, $restrictedCatIds)) {
        return $bypass;
    }

    // Grant access if user is owner or in authorized groups
    if ($user->id === $listing->owner_id || $user->isInGroups($authorizedUserGroups)) {
        return $bypass;
    }

    // Redirect unauthorized users
    fwd_redirect('/', 403);
    
    return true;
}, 20, 2);

Restrict Listing Detail Visibility to Logged In Users

Show signup/login page to guests instead of listing detail for restricted categories.

Eventy::addFilter('jreviews:listing.bypass-render.joomla', function($bypass, $article)
{
    // Change IDs to restricted category IDs
    $restrictedCatIds = [1, 2, 3];

    $user = fwd_auth()->user();

    $listing = \JReviews\App\Models\Listing::where('contentid', $article->id)->first();

    if (!$listing || !in_array($listing->cat_id, $restrictedCatIds)) {
        return $bypass;
    }

    // Logged in users can see the listing
    if ($user->isConnected()) {
        return $bypass;
    }

    // Show signup page for guests
    echo fwd_view('jreviews::site.components.account.signup-registration', [
        'registerUrl' => fwd_route('jreviews.account.register'),
    ])->render();

    exit;
    
    return true;
}, 20, 2);

Source Files

  • jreviews/cms_compat/joomla/includes/plugins/jreviews-joomla4.php
  • jreviews/cms_compat/joomla/includes/plugins/jreviews6.php
  • jreviews/cms_compat/joomla/packages/plugins/system/jreviews_articleoverrides/jreviews_articleoverrides.php