Create custom ItemStyle template for SharePoint - xslt

I've created a custom ItemStyle_ContactDetails.xsl for a SharePoint 2010 content query web part, which points to this custom file via the ItemXslLink property. The web part will be filtered to display only one record for that department's contact info. The list it's reading has these columns:
#Title -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#WorkAddress -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#PrimaryNumber -- built-in SharePoint column
#EMail -- built-in SharePoint column
#Opening_x0020_Hours -- custom multi-line rich text column
The above names are what they're called in the Data View Web Part from another site. I had the following in that DVWP that worked for a local site:
<td colspan="2" class="ms-vb" style="text-align:center">
<b><xsl:value-of select="#Title"/></b><br></br>
<div style="margin-top:10px;"><xsl:value-of
select="/dsQueryResponse/Rows/Row/#WorkAddress"/>
(MAP)
</div>
Tel: <xsl:value-of select="/dsQueryResponse/Rows/Row/#PrimaryNumber"/><br></br>
<xsl:value-of select="#EMail"/>
<p><b>Opening Hours:</b></p>
<div style="position:relative; top:0; margin:0">
<xsl:value-of select="#Opening_x0020_Hours"
disable-output-escaping="yes"/>
</div>
</td>
How do I translate this to the custom ItemStyle_ContactDetails.xsl template? The user needs to see the info without having to click a link to get to it -- it's always going to be just one record for that department. Thanks.

Some serious trial-and-error yielded the result, along with this great article: http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx
Maybe others trying this same thing can find this useful: You can edit the custom XSL file on the server via SPDesigner, but you can't do the same with the web part and hope to have the changes immediately reflected. You must export the content query web part, then edit the file in Notepad, etc., to make your changes to the following 3 items:
Change the ItemXslLink to point to your custom XSL file:
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/ItemStyle_ContactDetails.xsl</property>
Change the ItemStyle item in the web part to reference your template name; the template name in the XSL file is ContactDetails:
<xsl:template name="ContactDetails" match="Row[#Style='ContactDetails']" mode="itemstyle">
So in your web part, you'd have this:
<property name="ItemStyle" type="string">ContactDetails</property>
Update the CommonViewFields to list your custom columns and their types:
<property name="CommonViewFields" type="string">WorkAddress, Text; EMail,Text; Contact_x0020_Department,Choice; Map,URL; Opening_x0020_Hours,Text; PrimaryNumber, Text</property>
Save the web part file and import (upload) it via the browser to your web part gallery. Each time you make changes to the web part, you'll want to do this; the XSL file can be edited and saved in SPDesigner and the changes reflect immediately in the browser.
Hope this helps someone who gets stuck like I was :)

Whenever I edit "CommonViewFields" in the Webpart, I cannot edit the Properties after inserting the Webpart because of Correlation Error.
I am using SP 2013 onprem. Do I really need to modify the Webpart ? Isn't it enough to create a custom itemstyle.xls ?
I am playing around now for days. Each days more I have to say - Sharepoint is a mess.

Related

Sitecore Web Forms for Marketers, add info to the display-section-legend class

We are on Sitecore 8 using Web Forms for Marketers.
I am trying to identify how to add information to the "display-section-info" class item in a sitecore WFFM form. Looking # The generated code I see an element (display-section-info class) after the Field Legend, and before the starts of our fields. I would like to put some basic information regarding the fields in this element (below has text "THIS IS WHERE I WOULD LIKE TO ADD TEXT").
Here is the source from "View Source" on the browser. Through developer tools I plugged in some info and that is exactly where I want it to go.
<fieldset class="display-section-fieldset">
<legend class="display-section-legend">1. OUTSIDE INTEREST:</legend>
<p class="display-section-info">THIS IS WHERE I WOULD LIKE TO ADD TEXT</p>
<div class="display-section-content">
<div class=" field-border">
<span class=" field-title">
<span class=" field-required">*</span>
In the field below, list exceptions
</span>
Update1:
per Jammycans response I added a few parameters to the section but did not seem to display. items have been published, I also confirmed on the prod DB.
Content Editor
Results:
Thanks in advance
There is no field in the Form Editor to set this information, you can set it directly on the section item itself.
In the Content Editor, expand the form and select the Form Section item. On the section item in the Parameters field set the information field text you need:
<Information>THIS IS WHERE I WOULD LIKE TO ADD TEXT</Information>
You can use the Localized Parameters field if you need to translate the text.
EDIT:
There is a bug in the logic on the default WFFM section view, located in \Views\Form\EditorTemplates\SectionModel.cshtml (for Sitecore 8 update 5 and earlier). On lines 18-21, the code reads:
#if (string.IsNullOrEmpty(Model.Information))
{
<p class="#Model.CssClass display-section-info">#Html.Sitecore().Field("Information", Model.InnerItem)</p>
}
The first line here should read:
#if (!string.IsNullOrEmpty(Model.Information))
Note the "!". That explains why you were seeing the markup previously, even though the parameter was not set. You need to update the code in the view in order to fix it.

Sitecore WFFM Form not working when inserted as a web control

I created a form which works if I add it as control to Presentation --> Details. What I need to do on another page is inserting the same web form as a web control like this:
<wffm:FormRender FormID="{72857A3A-B6C5-48C0-995B-FA053C82870F}" runat="server" />
The form is shown on the page, but the validations report not filled fields, although they are filled.
Am I missing something?
There you go. This is what you need to do.
<wffm:FormRender FormID="{72857A3A-B6C5-48C0-995B-FA053C82870F}" FormTemplate="/sitecore modules/web/Web Forms for Marketers/Control/SitecoreSimpleFormAscx.ascx" runat="server" />

How to render a link with a query string in Sitecore

I am trying to generate a link field on to the page, in the below format
<a class="book__btn" href="https://oc.axis.com/rez.aspx?submit=&shell=CASGCF">
Book
</a>
aspx:
<sc:Link ID="lnkBook" runat="server" Field="Target URL"></sc:Link>
<sc:FieldRenderer ID="frBook" runat="server" FieldName="Target URL"></sc:FieldRenderer>
aspx.cs:
Item offerDetails = this.DataSource;
lnkBook.Item = offerDetails;
frBook.Item = offerDetails;
The pic shows my declarations using Rocks
When the page is previewed, the button does not render at all. However, if I remove the text in the Query String field, it renders fine.
The Sitecore Rocks interface is a little misleading for links because the applicable fields do not change based on the link type. Query String is only supported for internal links. If you want to add a query string to your external link, just add it directly to the Url.

How to get list column which is in xslt list view webpart in in JQuery?

I am customizing NewForm.aspx in SP2013 in Designer 2013. I am struggling to get column values from XSLT list view web part in SharePoint designer 2013. I need to manipulate with columns in JQuery to do some action (like hiding, disabling etc.). Currently, I am getting column ID via Developer tool hovering over it but this is not proper way since ID will change in Quality/Production.
Example:-
$("#ctl00_ctl33_g_1ea47d6f_1fed_4426_8e49_cda9970429d6_ff21_ctl00_ctl00_TextField").val("Close");
I want something like:-
$("#column2").val("Close");
My XSLT in SP Designer 2013 looks like:-
<tr><td>
<H3>column2</H3>
</td>
<td>
<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="Edit"
FieldName="column2" __designer:bind="
{ddwrt:DataBind('u',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(#ID)),'#column2')}"/>
<SharePoint:FieldDescription runat="server" id="ff3description{$Pos}" FieldName="column2" ControlMode="Edit"/>
</td>
</tr>
Please assist.
It's standard ASP.NET behavior that ID of server control is not ID of HTML element that is representing the control. And many of SharePoint controls are rendered by many DIVs and SPANs (especially columns like people, formatted text, ...). So reading and setting values of them is quite complicated process.
Generally you can use title attribute to search for HTML tag that contains HTML element of particular field. Title attribute contains name of the field. For required fields it contains also required information. Or you can try to search for elements with ID starting with internal name of the field. But in both cases you will need to add some additional logic to find the right control containing the value of the field. The logic will need to reflect the type of field you are looking for.
The easiest way is to use some libraries like SPJSutility or form designer to manipulate with form fields.
You can not disable even the simplest textboxes by setting enabled attribute to false because in that case the value will not be processed on the server.

Print all elements navItem list in openCMS

in my openCMS project, content folders are named by years:
2010
2011
2012
2013
I use
CmsJspNavBuilder navigation = a_cms.getNavigation();
List navItems = navigation.getSiteNavigation(a_rootFolder,99);
to create a list of all these folders. How do I print the whole list item by item?
Thanks!
I suggest to use the taglibs instead of java code, it's cleaner.
See the sample right there:
http://www.opencms-wiki.org/wiki/The_OpenCms_8_Demo_Template_Modules_in_Detail#Navigation_tag
<cms:navigation type="forFolder" startLevel="0" endLevel="1" var="nav"/>
<c:forEach items="${nav.items}" var="elem">
<c:set var="currentLevel" value="${elem.navTreeLevel}" />
[…]
<a href="<cms:link>${elem.resourceName}</cms:link>">
${elem.navText}
</a>
</c:forEach>
</cms:navigation>
From the wiki:
The tag provides access to the navigation information. The tag is described in the /WEB-INF/opencms.tld OpenCms tag library descriptor (TLD).
A Web Container (e.g. Tomcat) uses TLDs to validate tags.
The opencms.tld describes the custom OpenCms tag library.
The navigation tag has six attributes:
var (required)
type(required) can be set to treeForFolder, forFolder, forSite, forResource, breadCrumb
startLevel (optional) that reads the property "NavStartLevel" on resource or folder
endLevel (optional)
resource
param (optional).
Using the navigation tag in a JSP invokes the core method org.opencms.jsp.CmsJspTagNavigation used to access OpenCms VFS navigation information on a JSP with the EL.