Last active
April 27, 2018 19:12
-
-
Save stevewithington/2534b948393445a75709 to your computer and use it in GitHub Desktop.
Mura CMS : Example of how to get the version history of all content items, and how to export version history as a CSV file.
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
<cfscript> | |
// Example of how to get a CSV report of all content items | |
// Drop this under a temp directory under the Mura webroot | |
// You could explicitly set this to any siteid you want, if desired | |
if ( !IsDefined('$') ) { | |
siteid = StructKeyExists(session, 'siteid') ? session.siteid : 'default'; | |
$ = application.serviceFactory.getBean('$').init(siteid); | |
} | |
feedBean = $.getBean('feed').setMaxItems(0).setNextN(0); | |
it = feedBean.getIterator(); | |
</cfscript> | |
<cfheader name="Content-Disposition" value="attachment;filename=versionhistory.csv"> | |
<cfcontent type="text/csv">TITLE,STATUS,LASTUPDATE,LASTUPDATEBY | |
<cfoutput><cfif it.hasNext()><cfloop condition="#it.hasNext()#"><cfset item = it.next() /><cfset itHistory = item.getVersionHistoryIterator() /><cfloop condition="#itHistory.hasNext()#"><cfset hist = itHistory.next() />"#hist.getTitle()#","#hist.getStatus()#","#LSDateFormat(hist.getValue('lastupdate'))# #LSTimeFormat(hist.getValue('lastupdate'))#","#hist.getValue('lastupdateby')#" | |
</cfloop></cfloop></cfif></cfoutput> |
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
<cfscript> | |
// Example of how to view the Version History of all content items | |
feedBean = $.getBean('feed').setMaxItems(0).setNextN(0); | |
it = feedBean.getIterator(); | |
</cfscript> | |
<cfoutput> | |
<cfif it.hasNext()> | |
<ol> | |
<cfloop condition="#it.hasNext()#"> | |
<cfset item = it.next() /> | |
<li> | |
#item.getTitle()# | |
<ul> | |
<cfset itHistory = item.getVersionHistoryIterator() /> | |
<cfloop condition="#itHistory.hasNext()#"> | |
<cfset hist = itHistory.next() /> | |
<li> | |
#hist.getStatus()# : | |
#LSDateFormat(hist.getValue('lastupdate'))# #LSTimeFormat(hist.getValue('lastupdate'))# : | |
#hist.getValue('lastupdateby')# | |
</li> | |
</cfloop> | |
</ul> | |
</li> | |
</cfloop> | |
</ol> | |
</cfif> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment