Hiding/showing content by member tag
I've created a region and associated template to display Employees. I'd like their contact details only to be visible if the user is logged in and has the tag "Staff" and/or "Manager". If the user isn't logged in or the tag doesn't match the information isn't displayed.
I'm not sure how to use the <perch:member has-tag="staff">
to hide/show the following
<perch:content id="Telephone" type="text" label="Telephone" required="true" title="true" /><br/>
<perch:content id="Mobile" type="text" label="Mobile" required="true" title="true"/><br/>
<perch:content id="Email" type="text" label="Email" required="true" title="true"/></p>
Just wrap it:
Hi Drew,
That's what I thought, however when I view the page unlogged in I still see the 3 bits of information which should be hidden until I'm logged in (as a user tagged as staff.)
Are you using a
perch_content()
region? If so, swap it toperch_content_custom()
I wasn't so I've just changed it (deleted all the regions and the page itself and set it up from scratch) but the items remain visible when not logged in.
Do you see any Perch tags left in the page source?
Yes. there's a </perch:member> at the end of the block.
<article>
<h1>Who's who</h1><div class="staff-sticker"> <img src="/admin/resources/chrisgrimes.jpg" alt="Chris grimes" class="employee"/> <h2>Chris Grimes</h2> <p>Shop Manager</p> <p>Blah</p> <p>Well</p>
<p> 01386 700123<br/> 07970 123456<br/> manager@blockleyshop.co.uk</p> </perch:member>
</div> </article>
Interesting..! As an experiment, can you remove the
<br/>
tags and test again?I've removed the <br/> tags completely and the the 3 items are still visible and the stray </perch:member> is still appears in the source.
Can you show me your diagnostics report?
here goes…
Perch: 2.5.2 Production mode: Production (100) Installed apps: content (2.5.2), assets (2.5.2), perch_blog (4.1), perch_events (1.9), perch_forms (1.7), perch_newsfeed (1), perch_comments (1.1), perch_members (1.0.3), perch_backup (1.2), perch_twitter (3.2) DB driver: PDO DB tables: perch2_blog_authors, perch2_blog_categories, perch2_blog_comments, perch2_blog_posts, perch2_blog_posts_to_categories, perch2_blog_posts_to_tags, perch2_blog_sections, perch2_blog_tags, perch2_content_index, perch2_content_items, perch2_content_regions, perch2_events, perch2_events_categories, perch2_events_to_categories, perch2_forms, perch2_forms_responses, perch2_members, perch2_members_forms, perch2_members_member_tags, perch2_members_sessions, perch2_members_tags, perch2_navigation, perch2_navigation_pages, perch2_newsfeed, perch2_page_templates, perch2_pages, perch2_resource_log, perch2_resource_tags, perch2_resources, perch2_resources_to_tags, perch2_scheduled_tasks, perch2_settings, perch2_twitter_settings, perch2_twitter_tweets, perch2_user_privileges, perch2_user_role_privileges, perch2_user_roles, perch2_users Users: 1 App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_members/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_events/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_twitter/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_comments/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); ?> Scheduled tasks for perch_blog: delete_spam_comments (1440 mins) Scheduled tasks for perch_twitter: update_tweets (10 mins) Scheduled tasks for perch_newsfeed: update_news (1440 mins) Scheduled tasks for perch_events: update_category_counts (60 mins) Editor plug-ins: markitup H1: 98c7531319d7f05066c6540d805030d1 L1: b69f9248c209ba97ec1216d672fc6c4f headerColour: #ffffff content_singlePageEdit: 1 helpURL: siteURL: / hideBranding: 1 content_collapseList: 1 lang: en-gb update_2.4.3: done latest_version: 2.5.3 on_sale_version: 2.5.3 headerScheme: light content_hideNonEditableRegions: 1 dashboard: 1 content_frontend_edit: 0 logoPath: /admin/resources/Logo-BVSC.png update_2.4.5: done perch_events_update: 1.8 perch_members_login_page: /members/login.php?r={returnURL} perch_backup_mysqldump_path: /admin/backup perch_events_detail_url: /events/event.php?event={eventSlug} perch_twitter_update: 3.2 update_2.4.9: done hide_pwd_reset: 0 update_2.5: done update_2.5.2: done perch_blog_post_url: /blog/post.php?s={postSlug} perch_blog_slug_format: %Y-%m-%d-{postTitle} perch_blog_akismet_key: perch_blog_comment_notify: 1 perch_blog_max_spam_days: 1 perch_comments_akismet_key: perch_blog_update: 4.0 PERCH_DEVELOPMENT: 10 PERCH_STAGING: 50 PERCH_PRODUCTION: 100 PERCH_DB_USERNAME: cl52-blockley PERCH_DB_SERVER: localhost PERCH_DB_DATABASE: cl52-blockley PERCH_DB_PREFIX: perch2_ PERCH_EMAIL_FROM: web@blockleyhub.org PERCH_EMAIL_FROM_NAME: Nick Loat PERCH_LOGINPATH: /admin PERCH_PATH: /home/sites/blockleyhub.org/public_html/admin PERCH_CORE: /home/sites/blockleyhub.org/public_html/admin/core PERCH_RESFILEPATH: /home/sites/blockleyhub.org/public_html/admin/resources PERCH_RESPATH: /admin/resources PERCH_HTML5: 1 PERCH_SCHEDULE_SECRET: d0v3dale PERCH_ERROR_MODE: DIE PERCH_DATE_LONG: %d %B %Y PERCH_DATE_SHORT: %d %b %Y PERCH_TIME_SHORT: %H:%M PERCH_TIME_LONG: %H:%M:%S PERCH_DEBUG: PERCH_PREVIEW_ARG: preview PERCH_TEMPLATE_PATH: /home/sites/blockleyhub.org/public_html/admin/templates PERCH_DEFAULT_DOC: index.php PERCH_DEFAULT_EXT: .php PERCH_PRODUCTION_MODE: 100 PERCH_RWD: PERCH_HTML_ENTITIES: PERCH_SSL: PERCH_AUTH_PLUGIN: PERCH_DB_CHARSET: utf8 PERCH_DB_PORT: PERCH_DB_SOCKET: PERCH_APPS_EDITOR_PLUGIN: markitup PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile HOSTING SETTINGS
PHP: 5.5.9 Zend: 2.5.0 OS: Linux SAPI: cgi-fcgi Safe mode: not detected MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $ MySQL server: 5.5.33 Extensions: Core, date, ereg, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, pcntl, readline, Reflection, session, standard, shmop, SimpleXML, sockets, mbstring, tokenizer, xml, cgi-fcgi, bcmath, curl, dom, enchant, fileinfo, gd, imap, intl, json, ldap, exif, mcrypt, mssql, mysqlnd, mysql, mysqli, odbc, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, pspell, recode, soap, sqlite3, tidy, wddx, xmlreader, xmlrpc, xmlwriter, xsl, zip, mhash GD: Yes (image sharpening disabled, #66714) ImageMagick: No PHP max upload size: 64M PHP max form post size: 64M PHP memory limit: 128M Total max uploadable file size: 64M Resource folder writeable: Yes Session timeout: 24 minutes Native JSON: Yes Filter functions: Yes Transliteration functions: Yes PATH: /usr/local/bin:/usr/bin:/bin UNIQUE_ID: U8K-a38AAAEAAENG3S0AAAAH SCRIPT_URL: /admin/core/settings/diagnostics/ SCRIPT_URI: https://blockleyhub.org/admin/core/settings/diagnostics/ HTTP_HOST: blockleyhub.org HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.10 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.10 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 HTTP_REFERER: https://blockleyhub.org/admin/core/settings/diagnostics/ HTTP_ACCEPT_LANGUAGE: en-us HTTP_ACCEPT_ENCODING: gzip, deflate HTTP_COOKIE: _ga=GA1.2.1822467891.1403891935; __utmz=261751774.1404982319.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=261751774.1822467891.1403891935.1404982319.1404982319.1; __atrfs=ab/|pos/|tot/|rsi/53c2b2dd00000000|cfc/|hash/0|rsiq/|fuid/28e9ddbb|rxi/|rsc/|gen/1|csi/|dr/; __atuvc=1%7C26%2C219%7C27%2C326%7C28%2C28%7C29; PHPSESSID=0rtlt9lj13pcp2r83ctjckr4d7; cmsa=1 HTTP_CONNECTION: close SERVER_SIGNATURE: <address>Apache/2.4.9 (Unix) Server at blockleyhub.org Port 80</address> SERVER_SOFTWARE: Apache/2.4.9 (Unix) SERVER_NAME: blockleyhub.org SERVER_ADDR: 10.3.187.69 SERVER_PORT: 80 REMOTE_ADDR: 92.23.33.176 DOCUMENT_ROOT: /home/sites/blockleyhub.org/public_html/ REQUEST_SCHEME: http CONTEXT_DOCUMENT_ROOT: /home/sites/blockleyhub.org/public_html/ SERVER_ADMIN: webmaster@blockleyhub.org SCRIPT_FILENAME: /home/sites/blockleyhub.org/public_html/admin/core/settings/diagnostics/index.php REMOTE_PORT: 59227 GATEWAY_INTERFACE: CGI/1.1 SERVER_PROTOCOL: HTTP/1.1 REQUEST_METHOD: GET QUERY_STRING: extended REQUEST_URI: /admin/core/settings/diagnostics/?extended SCRIPT_NAME: /admin/core/settings/diagnostics/index.php PHP_SELF: /admin/core/settings/diagnostics/index.php REQUEST_TIME_FLOAT: 1405271916.0306 REQUEST_TIME: 1405271916
You should be getting a much shorter report than that. Was this a clean install of 2.5.2?
Yep, it was a while ago though, pre 2.5 upgraded as and when new versions have been released
Thats the extended report the summary info is thus…
Perch: 2.5.2, PHP: 5.5.9, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.5.2), assets (2.5.2), perch_blog (4.1), perch_events (1.9), perch_forms (1.7), perch_newsfeed (1), perch_comments (1.1), perch_members (1.0.3), perch_backup (1.2), perch_twitter (3.2) App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_members/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_events/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_twitter/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_comments/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); ?> PERCH_LOGINPATH: /admin PERCH_PATH: /home/sites/blockleyhub.org/public_html/admin PERCH_CORE: /home/sites/blockleyhub.org/public_html/admin/core PERCH_RESFILEPATH: /home/sites/blockleyhub.org/public_html/admin/resources Image manipulation: GD (image sharpening disabled, #66714) PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M Resource folder writeable: Yes HTTP_HOST: blockleyhub.org DOCUMENT_ROOT: /home/sites/blockleyhub.org/public_html/ REQUEST_URI: /admin/core/settings/diagnostics/ SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Will update to 2.5.3 see if that makes a difference.
Hi Drew,
Just updated to 2.5.3 unfortunately the problem still persists. Here's the latest diagnostics summary if that helps.
Perch: 2.5.3, PHP: 5.5.9, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.5.3), assets (2.5.3), perch_blog (4.1), perch_events (1.9), perch_forms (1.7), perch_newsfeed (1), perch_comments (1.1), perch_members (1.0.3), perch_backup (1.2), perch_twitter (3.2) App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_members/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_events/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_twitter/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_comments/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); ?> PERCH_LOGINPATH: /admin PERCH_PATH: /home/sites/blockleyhub.org/public_html/admin PERCH_CORE: /home/sites/blockleyhub.org/public_html/admin/core PERCH_RESFILEPATH: /home/sites/blockleyhub.org/public_html/admin/resources Image manipulation: GD (image sharpening disabled, #66714) PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M Resource folder writeable: Yes HTTP_HOST: blockleyhub.org DOCUMENT_ROOT: /home/sites/blockleyhub.org/public_html/ REQUEST_URI: /admin/core/settings/diagnostics/ SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
This is definitely being displayed using
perch_content_custom()
?Can you reduce it to a simpler test case?
I'll have a go.
Hi Drew,
I'm using the following to call define the regions
and then in then following in the template used for the Content region…
The members login is appears to be working because I can show and hide parts of the navigation depending on member tag.
I've tried a fresh install on another site and the same thing happens. (Including the stray </perch:member> tag showing up in the source)
So at any point are you checking if the member is logged in or not?
Hi Drew,
I think this is where I've got confused. I though that I was checking if the member was logged in by using the <perch:member has-tag="boardmember"> in the template to restrict the display of content. So do I need to check in the page also? Could you give me an example of what I should be doing - thanks.
I'm not sure - I'm just looking for clarification of what's on your page.