Skip to content

Instantly share code, notes, and snippets.

@jsieber
Created July 31, 2015 18:03
Show Gist options
  • Save jsieber/e82a2442ed34eda24f4e to your computer and use it in GitHub Desktop.
Save jsieber/e82a2442ed34eda24f4e to your computer and use it in GitHub Desktop.
Delete all "link" objects under same parent in Mura CMS
<cfscript>
// This will delete all items that have a type of link under the same parent at this page. Include this to a page in the same parent with the Mura tag.
// writeDump(var=$.content('type'), abort=true);
queryService=new Query();
queryService.setSQL(
'SELECT contentID, siteid
FROM tcontent
WHERE parentID = :parentID
AND siteID = :siteID
AND active = 1'
);
queryService.addParam(
name='parentID'
, cfsqltype='cf_sql_varchar'
, value=$.content('parentID')
);
queryService.addParam(
name='siteID'
, cfsqltype='cf_sql_varchar'
, value=$.content('siteID')
);
rs=queryService.execute().getResult();
iterator=$.getBean('contentIterator');
iterator.setQuery(rs);
</cfscript>
<cfoutput>
<cfif iterator.hasNext()>
<ul>
<cfloop condition="iterator.hasNext()">
<cfset item=iterator.next()>
<cfif item.getType() eq "link">
<li>
#HTMLEditFormat(item.getMenuTitle())# Deleted
</li>
<cfset item.delete() />
</cfif>
</cfloop>
</ul>
<cfelse>
<p class="alert alert-info">No items in the iterator to delete!</p>
</cfif>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment