Kentico Repeater Selected Item Transformation - kentico

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.

Related

Orchard Core CMS - Is it possible to get an existing content item, to be shown in another content item?

I've been struggling to show an existing content item to a another content item, what I can do as of now is just add the content part in a content item with using Flow and Bag, but the user really has to fill up the fields for these stuff. What I am trying to do here is for example make a styled 'button' (with the tags and such) with prefilled text in the button, then the user can edit it anytime within the content item it is called.
I am using orchard core with .net core 5.0
There are multiple ways to do this, the way I like to do it for styling is to make a content part with different fields, usually text fields and once the field is created, edit the field and change the editor type to predefined list, once this predefined list is created, one of them can be selected as default. Then add this content part as a part on the parent content type image of fields on contentpart image of predefined list
Another way would be to create a content picker field on an item, that's how you can include other content types on a parent item, I find this approach good for bigger content items (I.e. contentbanners etc) content banner content picker image
This approach is good but you have to use the contentitem filter (Liquid or razor) to get the content item as the parent content item only includes a reference to the content item and not the actual item.
{% for ContentItemId in Model.ContentItem.Content.ContentSections.Banners.ContentItemIds %}
{% assign contentSection = ContentItemId | content_item_id | shape_build_display: "Detail" %}
{{ contentSection | shape_render }}
{% endfor %}
The Third way, if you want content creators to add buttons etc in html editors etc would be via using shortcodes. shortcodes

Kentico - Dynamic Page Title Not Display Correctly in Smart Search Results

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.

Kentico 9 Hierarchical transformations for a menu system

My end goal is to have a page that displays a Heading then links.
The Heading text would come from child folder, and the links would be pages within that folder.
I'm not concerned about the actual HTML at this point, but say an h2 for the header, an LI for each link.
I had thought i could create a repeater with a transformation to grab the folder name, and then all the sub nodes, but i'm struggling here since I've never tackled something like this in Kentico before, and have never attempted to build a navigation system using hierarchical transformations.
Here's my current content tree
Missed Payments
Group
Arrears Overview
Arrears Deductions
Flex
When rendered, Missed Payments should have the following code. When i add mew pages to Group and Flex, page links are shown
<h2>Group</h2>
<ul>
<li><a href='link to overview'></a>Page Name</li>
<li><a href='link to deductions'></a>Page Name</li>
</ul>
<h2>Flex First</h2>
I have a Header, Item and Footer transformation types, with Header, Link and Footer transformation. The HTML is simple, but i'm missing the piece to bring it all together.
Have you looked at the Creating a Mega Menu using Hierarchical transformations how to on Kentico?
For your level 0 header have <ul><li>
Level 1 header have
<ul>
<li><h2>{% Documents[NodeAliasPath].Parent.DocumentName #%}</h2></li>
<li>
All levels item: <a href="{% Transformation.GetDocumentUrl() #%}" >{%DocumentName%}</a>
All level separator: </li><li>
Footer: </li><li>
Make sure transformation type is Text/XML

dropdown menu link to specifict section in a page

I have index.html and the catalog.html, in this page I have some Id in order to move throw diferents sections in that page.
I have a menu, with Hone and Catalog, this option it´s a dropdownmenu, so, what I need is if I´m index and clic on catalog can go to specific section (named "canal-prisma") of cataglo page, I have this code but didn´t work, thank you for your help
<li class="dropdown">
Catálogo<span class="caret"></span>
<ul class="dropdown-menu">
<li>CANAL PRISMA</li>
</ul>
Are you trying to go to a section on the page with the id or name attribute set as canal-prisma? If you set the id attribute, you should change that to the "name" attribute. Otherwise, more code is really needed to determine the answer to your question.
For example, in order to create a section of the page called canal-prisma:
Go to the Canal Prisma section
And in catalog.html:
<a name="canal-prisma">#</a>

Is it possible to format a NumberField in a page layout?

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

Resources