How do I make UGC DCPs work with REL?

157 Views Asked by At

I am building a primarily dynamic website in .NET and am trying to get UGC to work in conjunction with my Dynamic Component Presentations. My DCPs are being published using the REL output format (to the broker db), and are being consumed using the ComponentPresentationAssembler class.

The DCPs contain both a dynamic link and UGC PostRating. At runtime the dynamic link is successfully resolved, however the UGC code is not.

Example of DCP content in database:

<div>
<h2><tcdl:Link type="Component" origin="tcm:0-0-0" destination="tcm:33-10793" templateURI="tcm:0-0-0" linkAttributes="" textOnFail="true" addAnchor="false" variantId="">Basic Business Checking</tcdl:Link></h2>
    <tcdl:PostRating itemURI="tcm:33-10793" postParameter="ratingValuetcm:33-10793">
        <tcdl:ItemStats itemURI="tcm:33-10793">
            Rating:<tcdl:ContextVariable var="ugcItemStats.averageRating"/> (<tc    dl:ContextVariable var="ugcItemStats.numberOfRatings"/> ratings)<br/>
        </tcdl:ItemStats>
        <form method="post" id="ratingForm">Rate:
            <select name="ratingValuetcm:33-10793" size="1">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5" selected="true">5</option>
            </select>
            <input type="submit" value="Rate!"/>
        </form>
    </tcdl:PostRating>
</div>

.NET page code:

Query myQuery = new Query();
myQuery.Criteria = andCriteria;
string[] componentPresentationURIs = myQuery.ExecuteQuery();

ComponentPresentationAssembler componentPresentationAssembler = new ComponentPresentationAssembler("tcm:33-10796-64");

foreach (string componentPresentationURI in componentPresentationURIs) {
    Response.Write(componentPresentationAssembler.GetContent(componentPresentationURI, strComponentTemplateURI));
}

UGC is working successfully when deployed embedded on a page.
cd_dynamic_conf.xml is configured with ugc_renderer_bundle.xml tag bundle.

In the rendered html the dynamic link is resolved to

<a href="/prodigy/business-rewards-checking.aspx" >Business Rewards Checking</a>  

However the code remains as is.

And ideas would be welcome.

1

There are 1 best solutions below

2
On

First, a small remark: "REL tags cannot post comments/ratings" (check Enhancement Request 76605 logged with Tridion). That basically means that your "tcdl:PostRating" will be just removed from the resulting output. As far as it goes for "tcdl:ItemStats" and "tcdl:ContextVariable", they should be working just fine if you have the "ugc_dao_bundle.xml" setup in your "cd_storage_conf.xml". As a result, you will have the whole page rendered with all comments but Posting or Editing of comments/ratings will not work. If there is something wrong with your Rendering, then you should be seeing some errors in your logs. Hope this helps.

Cheers, Daniel.