Friday, July 3, 2015

Sample code for insite editing

1. How to code insite edit for image attribute (BLOB) ?

a. For Flex asset - blob attribute

<insite:edit field="largeThumbnail" assetid='<%=ics.GetVar("imageId")%>' assettype="AVIImage" list="largeThumbnail" column="value" > 
        <img class="photo left" src='<%=ics.GetVar("imageURL")%>' />
</insite:edit>

b. For Basic asset - blob attribute (url field)

<render:getbloburl
        c='<%=ics.GetVar("c") %>'
        cid='<%=ics.GetVar("cid") %>'
        asset="<asset instance name>"
        field="<asset field name>"
        outstr="theURL"/>
 
<insite:edit field="
<asset field name>" variable="theURL" assetid='<%=ics.GetVar("cid") %>' assettype='<%=ics.GetVar("c") %>' editor="upload">
    <img src='<%=ics.GetVar("theURL") %>'/>
</insite:edit>

2. How to code insite edit for recommendation asset?

<commercontext:getrecommendations collectionname="[RECO NAME]" listvarname="recoList" />
<insite:slotlist slotname="RecommendationLink" assetid='<%=ics.GetVar("recoId")%>' assettype="AdvCols" field="Manualrecs">
<ics:listloop listname="assetlist">   
        <ics:listget listname="assetlist" fieldname="assetid" output="Id"/>   
        <ics:listget listname="assetlist" fieldname="assettype" output="Type"/> 
                <insite:calltemplate tname="[Template Name]" c='<%=ics.GetVar("Type")%>'     cid='<%=ics.GetVar("Id")%>'/>
        </ics:listloop>
</ics:slotlist>

Note: Above code is applicable for only static list of recommendation.

3. How to limit characters for insite edit field?

<insite:edit variable="title" field="titleparams="{maxLength:20}"/>

4. How to code insite edit for CKEditor?

<insite:edit field="body"
              value="${asset.body}"
              editor="ckeditor"
              params="{noValueIndicator: 'Enter body ', width: '600px', height: '500px', toolbar: 'SITES', enableEmbeddedLinks:'1'}"/>

You can also create your own toolbar and add your toolbar name in params attribute in above code.

General instructions:
1. Add clegal param to restrict users from adding other asset type
2. Add cssstyle param for using any particular css file
3. Make use of <insite:ifedit> tag when extra slots/additional js or css are required to be loaded
4. Slot data gets lost when using CSDT+eclipse after editing template: Populate slots in CS and then sync with eclipse. If slots are changed, before coding for template in eclipse, first re-sync and then make changes.

Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...