How to get one of repeatable text field liferay7 Freemarker - liferay

I created a Web content Dsiplay ( Text as a repeatable field in structure ).
In the structure template i wanted to have only the third element.
I tried
${Text.getSiblings()[3].getData()}
But it doesn't work
I am using Liferay-7 and Freemarker as Stucture template
Thank you

Index fields start with 0 so the solution for the 3rd element is :
${Text.getSiblings()[2].getData()}

Related

how to set value in orchard core text field in asp net core

I'm trying to write my own API to fill an orchard core content type which has several text field. for example the content type named "test" has two fields named first name and last name and are text fields.
I know by using contentItem.Content.test.firstName.Text.Value I can get the value. but as I use contentItem.Content.test.firstName="Mary" and then calling createAsync, just a new content Item is created which is empty.
would you please help me?
thanks
ps:test is the part name too
I solved the problem by using dynamic object variable

Kentico 12 Azure Search

I'm trying to implement Azure Search on Kentico 12. Following the article below.
https://docs.kentico.com/k12/configuring-kentico/setting-up-search-on-your-website/using-azure-search/integrating-azure-search-into-pages
However, I have multiple indexes defined on the smart search not just a single index code name that I can hard code and also cannot aford to hard code index fields. Is there any tutorial out there that I can follow?
It sounds as if you're referring to building an Azure Search web part, is this correct. If so, make a property in your web part which allows you to select the code name from a list in the database. Secondly, regarding field names, you should be using generic field names like DocumentName, NodeAliaspath, etc. Although if you have very specific search results that need to be displayed, simply put in a switch statement to get the field names based on a class name.

Select a single document from Multiple Document Selector Kentico

I am using a Multiple Document Selector field on one of my document types, so the user can select many documents they like.
Now I would like to loop through each of those documents and apply some HTML tags, my current solution applies the same rule to all of those documents, what I need to be able to do is find the second document that has been selected on the multiple document selector and apply a different rule!
Does anyone know how I can find the second element or any single element from the multiple document selector control.
Hope someone can help me.
Thank you
The Multiple Document Selector is not a standard Kentico control so I don't know how the value is stored but I guess it's something like comma-separated list of NodeAliasPaths. E.g.:
/News/News-1, /Products/Phones, /Services
In that case you can use K# macro:
Documents["/Page"].MutipleDocumentField.Split(",")[0]
// Selects the first document in MultipleDocumentField on page with NodeAliasPath == "/Page"
or
CMSContext.CurrentDocument.MutipleDocumentField.Split(",")[1]
// Selects the second document in MultipleDocumentField on the current page
Macros can also use loops and have lots of built-in methods. See the documentation or the following example:
{% foreach (x in Documents["/Home"].SubmitText.Split(",")) {""+x+""} %}
In my case it generates the following HTML:
/Partners
/News
/Services
You can use macros in all web part fields. Try inserting the code e.g. to static text web part.

Orchard CMS: Content Item Get Field By Name in View

I have created a custom content type (via the admin UI) that consists mostly of text fields. I know how to position the fields using zones and Placement.info but for simplicity I would like to use a single view template and to just arrange the fields by name instead of having to use Placement.info. Is there a good way to reference the fields by name from the content item in my MVC view?
So for example, I have a template named Content-MyContentType-Detail.cshtml. Instead of the generic
#Display(Model.Content)
I would like to be able to do something like
#Display(...MyField...)
#Display(...MyOtherField...)
Is there a way to explicitly render a field by name that is associated with my content item?
You can use Shape Tracing module to view model properties and how to get access to content parts.
Then in your template you can use something like this:
<h3>#Model.ContentItem.TitlePart.Title - £#Model.ContentItem.Product.Fields[1].Value</h3>
<p>#Model.ContentItem.BodyPart.Text</p>
If you don't just want to access the field's properties, but rather would like its shape rendered in-place, but like it would be when using placement (i.e. using the existing template), then read this article, which describes how to do direct rendering without placement: http://weblogs.asp.net/bleroy/archive/2013/02/13/easy-content-templates-for-orchard-take-2.aspx

How to access cck fields in tpl file?

I am working on one already created drupal site. In themes folder it has one tpl.php file, Where theme is done to display the content. Now it is as follows
print $content
And all the fields of cck are displayed properly. But I want to access every field like Title, Body etc. I have tried with $content['title'], But nothing is displayed.
Can anyone please tell me how to access different fields in my tpl file. I am using Drupal 6.
Thanks in advance.
try to
<pre>
print_r($content);
</pre>
then you will see what's exactly in the array.
You can use node-[type].tpl.php to see the different fields. There, by default, each CCK field is exposed in a variable named with the field's name, for example if you have a field called field_logo then you have a variable called $field_logo which is an array representing the field's processed values and can be print_r()'d.
More template suggestions are available in Drupal documentation. And more information on using node.tpl.php and its derivatives is available too.

Resources