How to render a link with a query string in Sitecore - 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.

Related

How to link tags to search results in a Django Blog?

I am building a blog in django and am using django-taggit. I'm trying to figure out how to tie the link of a tag to a search result page that shows all of the posts using that tag.
I already have the search page created, I know how to filter queries to the page to bring the correct results, and know how to link to the page itself {% url 'search' %}. But how would I pass queries to the page from the template?
For instance, if I have a post tagged "dog" I want users to be able to click on the tag "dog" and be taken to the search page that only has results for posts also tagged "dog".
The django documentation for class views does not have examples of this. And every tutorial resource so far has been focused on the filtering and displaying of the search page itself rather than linking to it with desired queries in an <a> tag instead of a <form>.
In short, how do you make an <a> link pass a query into a url, like how an <input> would to a <form> action in Django?
I found the answer. Based on this , it is
<a href="{% url 'myview' %}?q=foobar">

Sitecore Rich Text links not user friendly when rendered through Glass

I have a component that includes a single Rich Text field. In the sublayout, the field is rendered as an Html.Editable with Glass so that it can be edited on the page in PageEditor. It looks like this:
public override void Initialize()
{
litBodyContent.Text = Html.Editable(GlassItem, item => item.Body);
}
<div style="min-height: 38px">
<asp:Literal runat="server" ID="litBodyContent" />
</div>
However, when I insert links using the Rich Text editor, when the page is rendered (in normal view after being published, not in page editor), the links are rendered with the item ID rather than the user friendly path, like this:
Go to another page
I am pretty sure that this is an issue with Glass. How can I keep the field editable in the Page Editor but make it render the link correctly?
You can check if you have proper attribute in the model.
If you have SitecoreFieldSettings.RichTextRaw attribute, it will NOT pass through render pipeline and returns the RAW HTML. Instead if you use Default (SitecoreFieldSettings.Default), rich text content will go through render pipeline and url will be in friendly format.
http://docs.glass.lu/html/d44739b2-5f0e-d862-f62c-86c50f0b262f.htm
Can you try to change it from using literal to use Editable() method directly, Something like:
<%= Editable(GlassItem, x => x.Body) %>
I think Initialize() is too soon in the page life cycle. Try moving it further along, like to Page_Load() or so.

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.

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.

Sitecore page editor render as HTML

I have a Sitecore item ("Content Item"), which has a rich text as "<h2>Header text</h2>".
I want this to be rendered as html.
But using a field renderer when I try
FieldRenderer1.Item = DatabaseManager.MasterDatabase.GetItem(//content item);
FieldRenderer1.FieldName = "Content";"
Text is rendered as "<h2>Header text</h2>" in the mark up. How do I get them render as HTML?
After reading the comments, I think may be trying this might work.
<sc:FieldRenderer id="HeaderText" runat="server" FieldName="HeaderText" />
This fixed my issues when I was trying something similar at my end.
FieldName specification is a must when it comes to FieldRenderers.