I need help setting up a CSS drop-down using macro. I created a new field, and under the data type I selected the dropdown. now back under transformation i paste the new field inside the class selector, but i dont see any of the class names i typed under form control.
<div class="alert {% AlertCssBackground %}" > <div>
There are a couple things you need to verify:
The drop-down field values are in the format
<value>;<display text>
For example:
red-bg;Red background
green-bg;Green background
What is stored in the database is the value. Which will be either red-bg or green-bg.
In your transformation, make sure you're using the proper type. If you're using macro syntax {% fieldName %} then you need to make sure you're using the Text/Html transformation type. If you're using the ascx format type <%# Eval("fieldName") %> then you need to use the ASCX transformation type.
If you stored the class name in the database field fieldName and you are using ascx page format then you can type <%# Eval("fieldName") %> in your transformation.
Related
I have a custom pagetype with 1 text field where I keep re-usable html content to be included on other pages through a repeater. The transformation for the repeater has just 1 line of code <%# Eval("Content") %>.
I'm running into a situation where I want to use a resource string inside the content box together with other html content, something like {$ site.languages $}. However, when viewing, the pages displays this string {$ site.languages $} instead of the value of the resource string. Is it possible to display the resource string content in this case and how?
Try using
<%# Localize(Eval("Content")) %>
Try this:
ASCX transformations – call the Localize transformation method:
<%# Localize("Text containing localization expressions: {$stringKey$}") %>
Text / XML transformations – use localization string macro expressions or the
GetResourceString macro method:
{$stringKey$} - OR - {% GetResourceString("stringKey") %}
I used {% CurrentDocument.DocumentName %} in the Metadata > page title field. The Title tag displays ok when viewing the article itself on the browser; however, when searching through Smart Search, the results output something like below in place of the Title. I'm not sure why, is there a way to fix this? Thanks!
{% CurrentDocument.DocumentName |(user)myLogin|(hash)9f2b69705f777e8a884a107dfb72f681d8eb99867b6967514dbdca851b7f4309%}
Note: This is for hundreds of article pages, and inheriting Page Title from Parent by using the macro work best for me.
What is your transformation for search results? How do you retrieve that value?
I can see two possible approaches to solve your issue:
go to page type -> search fields and select DocumentName as a value for Title field
adjust search results transformation and use <%# GetSearchValue("DocumentName") %> instead of <%# Eval("Title") %>
This is most likely because the user who signed the macro is not in the system any longer. I'd change the macro to simply read:
{%CurrentDocument.DocumentName#%}
Having the # at the end will say the macro does not need to be signed.
I'm having an issues with two repeaters, both using the same Selected Item Transformation. Each repeater is fed by a separate Page Data Source, since i also have pagination.
When an item from repeater 1 is selected, i see the memo data, but also repeater 1 table header, and all of repeater 2's table. Is it possible to set up a new page template for this, and have the memo detail show there?
Here is the memo landing page:
And here is the detail page:
Here's the tranformation code:
<section id="memoDetail">
<h1>Memorandum</h1>
<ul id="memoHeader">
<li><span class="headerLabel">To:</span> {% To %}</li>
<li><span class="headerLabel">From:</span> {% From %}</li>
<li><span class="headerLabel">Subject:</span> {% Subject %}</li>
<li><span class="headerLabel">Date:</span> {% Date %}</li>
</ul>
<div id="memoDetails">{% Details %}</div>
</section>
I believe you're using the same page template for items listing as well as details pages. The answer is yes, you can have different templates for those pages. You'll have to update each page shown in the repeater with new template in this case.
However this is not necessary: you may try to hide second repeater, e.g. base on page type, if repeaters show pages of different type, or put some visibility macro there.
I'm not sure why does header shows up on the second screenshot - there should be something wrong with repeater setting.
Mark, there is a way to force all the content for a page type to be display using a dedicated template. Go to Page Types app > select the page type > General > New page settings > Default page template, and set it there. This way, it doesn't matter where the items are listed by whatever repeaters, they will be displayed with the same template.
In my Thymeleaf template I need to set a custom attribute to a dynamically generated value. How would I do that?
I tried th:attr="name=value", but it seems to be pretty much strict about the 'value' part. For instance, I tried to generate the following attribute:
<div ng-init="myUrl='http://myhost.com/something'> ... </div>
where http://myhost.com/something is a dynamic part of the ng-init attrubute and is generated by Thymeleaf's URL expression, like #{...}
Any suggestions how to compose an expression that would produce the above piece of HTML?
Give this a try:
<div th:attr="ng-init='myUrl=\'' + #{http://myhost.com/something} + '\''">...</div>
It will output:
<div ng-init="myUrl='http://myhost.com/something'">...</div>
I'm developing a SharePoint publishing site and setting up its content types and page layouts. I need to display the value for a Year field with type Number. The markup currently is:
<SharePointWebControls:NumberField FieldName="Year" runat="server" id="Year" />
The problem with the default behaviour is that it shows each number with a comma, e.g. "2,009" instead of "2009". Is there a way I can set some sort of String.Format syntax on the field to make it display correctly?
I tried creating a new rendering template which looks like this:
<SharePoint:RenderingTemplate ID="YearNumberField" runat="server">
<Template>
<SharePoint:FormField ID="TextField" runat="server"/>
</Template>
</SharePoint:RenderingTemplate>
... but there doesn't appear to be any 'Format' property on the FormField object.
Thanks for any help.
Update:
I tried wrapping the SharePoint:FormField tag inside SharePoint:FormattedString. Unfortunately the field was not formatted, same results as this question.
The issue is that the rendering template must use FormField. This always renders the value in the format: 1,989 . To resolve this the rendered text needs to be trapped and altered to get the desired output. Here are two approaches to resolving this:
1. Write a custom control inherited from NumberField
The RenderFieldForDisplay and RenderFieldForInput methods can be overridden to provide the desired output. Additional properties can be added to the control to describe additional behaviour.
Pros: No changes to rendering templates required.
2. Write a custom control for use in the rendering template
A control that (for example) uses regular expressions to alter text can wrap around the FormField control.
<SharePoint:RenderingTemplate ID="YearField" runat="server">
<Template>
<RX:RegexManipulatorControl runat="server"
Mode="Replace"
Expression=","
Replacement="">
<SharePoint:FormField runat="server"/>
</RX:RegexManipulatorControl>
</Template>
</SharePoint:RenderingTemplate>
Pros: Generic solution can be used for any type of field.
from Just Another SharePoint Blog
Open the list view in SharePoint
Designer.
Right click on the data view web part.
(the list)
Select Convert to XSLT Data View
Click on the number field you would
like to format
A > will appear showing Data Field,
Format As
Click on the link below Format As -
Number formatting options
Under Options deselect Use 1000
separator
Click OK
Save your changes and hit F12 to
preview