Sava CMS Content Ratings Portal Inheritance
Before I begin....
I am really starting to enjoy Sava CMS the guys/girls are a credit to the CF community. The helpfulness on their forum is also very commendable, there were cases where I asked a question or made simple feature requests and they updated the version of Sava with fixes or the features within hours of the request.
I have decided to start making some little write ups and contribute in anyway I can. I don't fully know the system yet or make claims to be any CF guru as i am just starting out, however I like to learn so don't shoot me down straight away.
There also maybe other ways in Sava that I have not yet investigated do so some of the things I suggest here or in anyother post I make. The main problems I have found are with SEO in Sava, however I will post bits on that as I play.
Content Ratings Portal Inheritance
The first thing I wanted to write about was a simple fix on an issue I had setting up a portal and adding the content rating to it.
In Sava to stop the repetitive task of manually adding objects like the 'content rating' to every new page created under a portal you can you setup a portal with Inheritance Rules such as 'Start New Cascade', this means that anything added under that particular portal will inherit the display object(s) by default of the Portal its under.
However the portal page itself also has the display object on it when you do this. Its only the content I wanted to be rated not the actual portal page so this needed removing.
To do this you will have to change the display object a little.
Edit the file found in siteid/display_objects/rater/index.cfm
We are then going to make use of the content Bean getcontentType() they have so helpfully provided to find out what page the object is being displayed on..
2 <cffunction name="getcontentType" returnType="string" output="false" access="public">
3 <cfreturn variables.instance.ContentType />
4 </cffunction>
First set a argument to which we can check a condition against, in that argument add the content bean like below
There you go, simple! I am not sure if this is an bug as I don't see why you would ever need the ratings on the portal page, but someone could.
Full code is below, I will try to make my next post shorter (I know this could have been written in 2 sentences)
2
3 Sava CMS is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, Version 2 of the License.
6
7 Sava CMS is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with Sava CMS. If not, see <http://www.gnu.org/licenses/>. --->
14
15<cfsilent>
16<cfswitch expression="#getJsLib()#">
17 <cfcase value="jquery">
18 <cfset addToHTMLHeadQueue("jquery.cfm")>
19 <cfset addToHTMLHeadQueue("rater/htmlhead/rater-jquery.cfm")>
20 </cfcase>
21 <cfdefaultcase>
22 <cfset addToHTMLHeadQueue("prototype.cfm")>
23 <cfset addToHTMLHeadQueue("rater/htmlhead/rater-prototype.cfm")>
24 </cfdefaultcase>
25 </cfswitch>
26<cfset addToHTMLHeadQueue("rater/htmlhead/rater.cfm")>
27
28<cfparam name="request.rate" default="0" />
29<cfset request.raterID=listFirst(getAuthUser(),'^') />
30<cfif listFind(request.doaction,"saveRate") and request.raterID neq ' and isNumeric(request.rate)>
31<cfset myRate=application.raterManager.saveRate(
32request.contentBean.getcontentID(),
33request.siteID,
34request.raterID,
35request.rate) />
36<cfelse>
37<cfset myRate = application.raterManager.readRate(
38request.contentBean.getcontentID(),
39request.contentBean.getSiteID(),
40request.raterID) />
41</cfif>
42<cfset rsRating=application.raterManager.getAvgRating(request.contentBean.getcontentID(),request.contentBean.getSiteID()) />
43<cfset argument.thisType=#request.contentBean.getType(request.siteid,request.contentBean.getcontentid())# />
44</cfsilent>
45<cfoutput>
46<cfif argument.thisType neq "Portal">
47<div id="svRatings" class="clearfix">
48 <div id="rateIt">
49 <h3>Rate this</h3>
50 <form name="rater1" id="rater1" method="post" action="">
51 <input type="hidden" id="rate" name="rate" value="##">
52 <input type="hidden" id="userID" name="userID" value="#request.raterID#">
53 <input type="hidden" id="loginURL" name="loginURL" value="#application.settingsManager.getSite(request.siteid).getLoginURL()#&returnURL=#URLencodedFormat(getCurrentURL(true,'doaction=saveRate&rate='))#">
54 <input type="hidden" id="siteID" name="siteID" value="#request.siteid#">
55 <input type="hidden" id="contentID" name="contentID" value="#request.contentBean.getcontentID()#">
56 <input type="hidden" id="formID" name="formID" value="rater1">
57 <fieldset>
58 <label for="rater1_rater_input0radio1"><input type="radio" name="rater1_rater_input0" id="rater1_rater_input0radio1" value="1" class="stars" <cfif myRate.getRate() eq 1>checked</cfif> >Not at All</label>
59 <label for="rater1_rater_input0radio2"><input type="radio" name="rater1_rater_input0" id="rater1_rater_input0radio2" value="2" class="stars" <cfif myRate.getRate() eq 2>checked</cfif>>Somewhat</label>
60 <label for="rater1_rater_input0radio3"><input type="radio" name="rater1_rater_input0" id="rater1_rater_input0radio3" value="3" class="stars" <cfif myRate.getRate() eq 3>checked</cfif>>Moderately</label>
61 <label for="rater1_rater_input0radio4"><input type="radio" name="rater1_rater_input0" id="rater1_rater_input0radio4" value="4" class="stars" <cfif myRate.getRate() eq 4>checked</cfif> >Highly</label>
62 <label for="rater1_rater_input0radio5"><input type="radio" name="rater1_rater_input0" id="rater1_rater_input0radio5" value="5" class="stars" <cfif myRate.getRate() eq 5>checked</cfif>>Very Highly</label>
63 <!---<input type="submit" value="rate it" class="submit">--->
64 </fieldset>
65 </form>
66 </div>
67 <div id="avgrating">
68 <cfif rsRating.theCount gt 0>
69 <h3>Average Rating (<span id="numvotes">#rsRating.theCount# vote<cfif rsRating.theCount neq 1>s</cfif></span>)</h3>
70 <div class="ratestars rating#application.raterManager.getStarText(rsRating.theAvg)#<!--- #replace(rsRating.theAvg(),".","")# --->">
71 <cfif isNumeric(rsRating.theAvg)>#rsRating.theAvg#<cfelse>0</cfif>
72 <!--- <img id="ratestars" src="#application.configBean.getContext()#/#application.settingsmanager.getSite(request.siteid).getDisplayPoolID()#/images/rater/star_#application.raterManager.getStarText(rsRating.theAvg)#.gif" alt="<cfif isNumeric(rsRating.theAvg)>#rsRating.theAvg# star<cfif rsRating.theAvg gt 1>s</cfif></cfif>" border="0"> ---></div>
73 </cfif>
74 <script type="text/javascript">
75 initRatings('rater1');
76 </script>
77 </div>
78</div>
79</cfif>
80</cfoutput>





There are no comments for this entry.
[Add Comment] [Subscribe to Comments]