Forked from stevewithington/getCustomSearch.cfm
Last active
December 30, 2015 00:42
-
-
Save pauldenato/24802cae35952875f988 to your computer and use it in GitHub Desktop.
Get the Content a User most Recently Updated or is Credited in.
This file contains 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
<!--- Adapted from Steve's original gist - https://gist.github.com/stevewithington/5880459 getCustomSearch.cfm ---> | |
<!--- Needed a way to display content a user was credited for or had edited on the front end ---> | |
<!---Add this to the Theme or Site contentrenderer.cfc---> | |
<cffunction name="getUserActivity" output="no"> | |
<cfargument name="authorid" default="" required="yes" /> | |
<cfscript> | |
var local = {}; | |
local.feed=$.getBean('feed'); | |
local.feed.setMaxItems(0); // 0=unlimited | |
//create user to get more information for search params | |
local.user = $.getBean('user').loadBy(userid=arguments.authorid); | |
// SORTING :: you could have another field on your search form to filter on these fields | |
local.feed.setSortBy('lastUpdate'); // lastUpdate, releaseDate, displayStart, menuTitle, rating, comments, created, orderno, random | |
local.feed.setSortDirection('desc'); // asc, desc | |
// Create a grouping | |
if ( Len(Trim(arguments.authorid)) ) { | |
local.feed.addParam(relationship='andOpenGrouping'); | |
//use the id to get all of the current users last updates | |
local.feed.addParam( | |
relationship='OR' | |
,field='tcontent.lastUpdateByID' | |
,dataType='varchar' | |
,criteria=Trim(local.user.getValue('userid')) | |
,condition='CONTAINS' | |
); | |
//use first name to get and credits with the current users first & last name (not ideal) | |
local.feed.addParam( | |
relationship='OR' | |
,field='tcontent.credits' | |
,dataType='varchar' | |
,criteria=Trim(local.user.getValue('fname') & ' ' & local.user.getValue('lname')) | |
,condition='CONTAINS' | |
); | |
// could add more fields and/or extended attributes to search on here | |
local.feed.addParam(relationship='closeGrouping'); | |
} | |
return local.feed.getQuery(); | |
</cfscript> | |
</cffunction> | |
<!--Then add this to a template, new display object or component----> | |
<cfoutput> | |
<cfloop query="#$.getUserActivity($.currentUser().getValue('userid'))#" > | |
<div class="panel panel-default"> | |
<div class="panel-heading"> | |
<h3 class="panel-title">#title# <span class="badge pull-right"><span class="glyphicon glyphicon-pencil"></span></span></h3> | |
</div> | |
<div class="panel-body">#summary#</div> | |
<div class="panel-footer"></div> | |
</div> | |
</cfloop> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment