RatingControl problem

Ramón Almarza asked on March 18, 2014 07:57

Good morning,

We’re trying to use a CMS: RatingControl WebPart to rating a kind of documents in a section of one of our website. We’d like to use it in a transformation, so we’re trying to follow your instructions for that: http://devnet.kentico.com/docs/devguide/index.html?displaying_ratings_in_transformations.htm

I’m going to explain you how our site is built:

This is our tree of nodes:

-Aplicaciones

------Aplicaciones oficiales

--------------AppAndroid

--------------AppIPhone

--------------AppWindows phone

------Aplicaciones Android

--------------Metro

--------------UrbanStep

--------------Moovit

------Aplicaciones Apple

--------------gobus

--------------madridBus

--------------Moovit

------Aplicaciones WindowsPhone

--------------gobus

And nodes under “Aplicaciones oficiales”, “Aplicaciones Android”, “Aplicaciones Apple” and “Aplicaciones Windows Phone” are the documents that we want to rate. This documents are a custom types of documents created by us named custom.aplicacionOpendata.

“Aplicaciones” is a Page Item that contains a repeater WebPart for listing CMS.MenuItem document types under “Aplicaciones” Node, that corresponding with “Aplicaciones oficiales”, “Aplicaciones Android”, “Aplicaciones Apple” and “Aplicaciones Windows Phone” nodes, and the transformation used is this:

<%@ Register Src="~/CMSWebParts/Babel/EMT/OpenData/aplicacionesOpendata.ascx" TagName="aplicaciones" TagPrefix="uc1" %> <uc1:aplicaciones ID="infoGenerica" runat="server" />

And the code for AplicacionesOpendata.ascx is:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="aplicacionesOpendata.ascx.cs" Inherits="CMSWebParts_Babel_EMT_Opendata_AplicacionesOpendata" %> <%@ Register Src="~/CMSAdminControls/ContentRating/RatingControl.ascx" TagName="RatingControl" TagPrefix="cms" %> <div class="tab-pane" id="<%# Eval("DocumentName").ToString().Replace(" ","") %>"> <cms:CMSRepeater runat="server" ID="rptCuerpo" Path="./%" ClassNames="custom.aplicacionOpendata" TransformationName="custom.aplicacionOpendata.Default" FilterName="" MaxRelativeLevel="1" OrderBy="NodeOrder" DelayedLoading="true"> </cms:CMSRepeater>

In custom.aplicacionOpendata.Default transformation, we’re included the RatingControl as you can see below:

<%@ Register Src="~/CMSAdminControls/ContentRating/RatingControl.ascx" TagName="RatingControl" TagPrefix="cms" %>

" alt="<%# Eval("Titulo") %>">
<%# Eval("Titulo") %>
<%# Eval("Descripcion") %>" tooltip="<%# Eval("Titulo") %>"><%# Eval("Titulo") %>

This code aparently works fine, but all the ratingControl used show the rating for “Aplicaciones” document, and when somebody votes, the rating is saved for this document too, not for the “custom.aplicacionopendata” document that would correspond.

How can I solve this problem??

Thanks in advance,

Best regards.

Recent Answers


Richard Sustek answered on March 22, 2014 04:26

Hi,

Thank you for your message.

I see what you are trying to do, however the content rating webpart saves the value for the current document only. So even if you place it in transformation it will take into account only the document where the transformation is added.

You can see in the example which you posted that this is used on a Selected item transformation, not on a transformation where multiple documents are getting rendered.

The fix for this would be to let know the content webpart which document you want to rate by giving it another property like "DocumentIDtoVote" so that the controls knows which document to rate. Unfortunately it doesnt support this yet.

In order to implement this functionality I suggest creating new webpart which would be a substitution for our rating webpart where you would however need to code the functionality and update the ratings of the document manually.

The ratings to document can be added with a:

CMS.DocumentEngine ► TreeProvider ► AddRating method

We are sorry for the inconviniences.

Kind regards,

Richard Sustek

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.