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>



Recent Comments