Difference between revisions of "How to make part of theme visible only to listing owners"
From JReviews Documentation
(Created page with "It is possible to display certain information (part of the theme file) only to the listing owner using this conditional: <source lang="php"> <?php if($listing['User']['user_id']...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <div class="successbox" style="width: 95%"> | ||
+ | |||
+ | [https://www.jreviews.com/docs/theme-resources/conditionals-based-on-user-authentication There's a new version of this article] | ||
+ | |||
+ | </div> | ||
+ | |||
It is possible to display certain information (part of the theme file) only to the listing owner using this conditional: | It is possible to display certain information (part of the theme file) only to the listing owner using this conditional: | ||
<source lang="php"> | <source lang="php"> | ||
− | <?php if($listing['User']['user_id'] == $ | + | <?php if($listing['User']['user_id'] == $this->auth->id): ?> |
This will be visible only to the listing owner | This will be visible only to the listing owner | ||
Line 11: | Line 17: | ||
If you want to display certain information to listing owners and site admins as well, use this conditional: | If you want to display certain information to listing owners and site admins as well, use this conditional: | ||
+ | |||
+ | '''JReviews 3''' | ||
<source lang="php"> | <source lang="php"> | ||
− | <?php if($listing['User']['user_id'] == $ | + | <?php if ( $listing['User']['user_id'] == $this->auth->id || $this->auth->admin ): ?> |
This will be visible only to the listing owner and site admin | This will be visible only to the listing owner and site admin | ||
Line 20: | Line 28: | ||
</source> | </source> | ||
+ | |||
+ | '''JReviews 2''' | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php if($listing['User']['user_id'] == $User->id || $this->Access->isAdmin()): ?> | ||
+ | |||
+ | This will be visible only to the listing owner and site admin | ||
+ | |||
+ | <?php endif; ?> | ||
+ | </source> | ||
The above examples will only work in theme file where the $listing array is available: | The above examples will only work in theme file where the $listing array is available: |
Latest revision as of 23:56, 8 July 2020
It is possible to display certain information (part of the theme file) only to the listing owner using this conditional:
<?php if($listing['User']['user_id'] == $this->auth->id): ?> This will be visible only to the listing owner <?php endif; ?>
If you want to display certain information to listing owners and site admins as well, use this conditional:
JReviews 3
<?php if ( $listing['User']['user_id'] == $this->auth->id || $this->auth->admin ): ?> This will be visible only to the listing owner and site admin <?php endif; ?>
JReviews 2
<?php if($listing['User']['user_id'] == $User->id || $this->Access->isAdmin()): ?> This will be visible only to the listing owner and site admin <?php endif; ?>
The above examples will only work in theme file where the $listing array is available:
- /listings/detail.thtml
- /listings/detail_tabs.thtml
- /listings/detail_compact.thtml
For below files the $listing variable is available only inside the foreach($listings AS $listing) loop:
- /listings/listings_blogview.thtml
- /listings/listings_blogview_compact.thtml
- /listings/listings_tableview.thtml
- /listings/listings_thumbview.thtml
- /listings/listings_masonry.thtml
- /modules/listings.thtml