I have just recently been playing with mura in the last 2 days which I decided to use for the new CFLIVE website.
One function I need is to have menus/pages which will only be visible to logged in users. While Mura does allow you to restrict access to pages, it still displays the menus/links and allows access to the page but gives a login prompt instead of the page content, I could not find any way to hide the menu links as well.
On the Mura forums even BlueRiver themselves have suggested the only option is to create a hard coded menu instead, which really seems like a terrible work around to me, although that reply was 5 years old, so perhaps there was no better way to do it back then.
Anyway I found a better solution, but please be aware as I said, I have only been using Mura for 2 days, and have no more than a few hours experience with Mura code at this point, so if there is a better way of doing this, feel free to let me know.
Open the file /requirements/mura/content/contentRenderer.cfc
find the "allowlink function, around line 287 and copy this function to your site's contentRenderer.cfm
e.g.
[site root]/default/includes/contentRenderer.cfc
now simply add the <cfelseif> block below, this will stop restricted pages showing in the menu if the user is not logged in.
<cfif arguments.loggedIn and (arguments.restrict)> <cfif arguments.restrictgroups eq '' or listFind(session.mura.memberships,'S2IsPrivate;#application.settingsManager.getSite(variables.event.getValue('siteID')).getPrivateUserPoolID()#') or listFind(session.mura.memberships,'S2')> <cfset allowLink=True> <cfelseif arguments.restrictgroups neq ''> <cfset allowLink=False> <cfloop list="#arguments.restrictgroups#" index="G"> <cfif listFind(session.mura.memberships,'#G#;#application.settingsManager.getSite(variables.event.getValue('siteID')).getPublicUserPoolID()#;1')> <cfset allowLink=true> </cfif> </cfloop> </cfif> <!--- add this bit ---> <cfelseif !arguments.loggedin and arguments.restrict> <cfset allowLink=false> </cfif>
Oct 17, 2013 at 4:54 PM Should be able to use the local site renderer.cfc to override the global; won't be overwritten on a core file update:
http://docs.getmura.com/developer-guides/back-end-development/contentrenderercfc/
Oct 31, 2013 at 1:16 PM Thanks, I have updated article accordingly.
Apr 24, 2014 at 5:25 PM Hi Russ,
Thanks for posting this. I just wanted to provide a quick clarification. You *can* hide navigation, it just has to be behind a node that is password protected. For example, say you have a "resources" Mura folder/section for your employees, you would post all the content under that node. When you go to that page, you would prompted with a login and would not see the links until you logged in. I realize that this doesn't address all scenarios, but I wanted to make sure you were aware of this approach. Thanks again!
Jun 1, 2014 at 6:50 PM Did not work for me as it was.
I tried it in the MuraFoundations theme. No results.
Core 6.1.5896
What did seem to work though was removing arguments.restrict from your <cfelseif . . .
Thanks for the post!
Carl
Sep 18, 2014 at 11:20 AM Hi,
I have explained how this all works (also menus) in this blogpost: http://blog.onlinebase.nl/index.cfm?entry=220&category=10 - this also affects the menus in this setup, as long as the menuitem is part of or beneath a restricted element.