Created
January 9, 2015 20:06
-
-
Save stevewithington/13233e1d6369f2b320f1 to your computer and use it in GitHub Desktop.
Mura CMS: Get status of content (e.g., Draft, Pending Approval, Published, Archived)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Drop these methods in your Site or Theme contentRenderer.cfc, and get the status with $.getContentStatus() ---> | |
<cffunction name="getContentStatusID" output="false"> | |
<cfset var statusid = '' /> | |
<cfif $.content('active') gt 0 and $.content('approved') gt 0> | |
<!--- 2: Published ---> | |
<cfset statusid = 2> | |
<cfelseif len($.content('approvalstatus')) and $.content().requiresApproval()> | |
<!--- 1: Pending Approval ---> | |
<cfset statusid = 1 /> | |
<cfelseif $.content('approved') lt 1> | |
<!--- 0: Draft ---> | |
<cfset statusid = 0 /> | |
<cfelse> | |
<!--- 3: Archived ---> | |
<cfset statusid = 3 /> | |
</cfif> | |
<cfreturn statusid /> | |
</cffunction> | |
<cffunction name="getContentStatus" output="false"> | |
<cfset var status = '' /> | |
<cfif IsDefined('session.rb')> | |
<cfswitch expression="#getContentStatusID()#"> | |
<cfcase value="0"> | |
<cfset status = $.rbKey('sitemanager.content.draft') /> | |
</cfcase> | |
<cfcase value="1"> | |
<cfset status = $.rbKey('sitemanager.content.#$.content('approvalstatus')#') /> | |
</cfcase> | |
<cfcase value="2"> | |
<cfset status = $.rbKey('sitemanager.content.published') /> | |
</cfcase> | |
<cfdefaultcase> | |
<cfset status = $.rbKey('sitemanager.content.archived') /> | |
</cfdefaultcase> | |
</cfswitch> | |
</cfif> | |
<cfreturn status /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment