I am still pretty green when it comes to Kentico. I've attempted something like:
{% SettingsHelper.AppSettings["CMSApplicationName"] #%}
But nothing is returned.
I've looked at some of the Kentico 8.2 documentation but the answer eludes me.
The SettingsHelper is not an available Macro for you to use but an API. The out of box Macro is something like this
{% Settings.Content.PageNotFound.CMSPageNotFoundUrl #%} or {% Settings.GetValue("CMSPageNotFoundUrl", "") #%}
which you can get Settings value from the Settings application.
If you want to get the AppSettings value in the web.config but use Macro, you will need to write a custom macro Create custom macro
pass in the keyname into the method, and use the API you have to return the value.
Related
I have a component that uses two different resources in its HTL/Sightly template.
Is there a way to pass a parameter, to the say in my example the eventResource template, so that I can depending on this passed paramter change a css class on it?
<ul data-sly-list.teasers="${model.resourceList}" class="teaser-list-alternating c-list--reset">
<sly data-sly-test="${teasers.eventTeaser}"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser'}"></sly>
<li data-sly-test="${teasers.contentTeaser}" class="l-stack l-stack--horse"
data-component-hook-content-hub="teaser"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/contentHubTeaser'}"></li>
</ul>
I tried using data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='blabla'} to no availability.
#RequestAttribute(name = "contentHub")
private String contentHub;
The requestAttribute contentHub in the eventTeaser model is alway null and I am not sure how to get the selectors value in the eventTeaser template.
I can do it using TypeScript on the front end part but it is not very clean.
I was able to solve it using the selectors indeed and reading the selector value directly from the other sightly template. Here is the documentation I refered to:
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='inContentHub'}
In the eventTeaser template I then used the following:
data-sly-set.inContentHub="${'inContentHub' == request.requestPathInfo.selectorString}
and depending on the value of the inContentHub variable I was able to change the css class which was my ultimate goal.
I am quite new to Typo3 and Fluid, but I guess what I am after is quite basic.
As an Analogy: Twig can extended, so it is possible to create a custom function which can be used like that:
{% set id = uid() %}
<input id="{{ id }}" … /><label for="{{ id }}">…</label>
Is such a thing possible with Fluid? Do I need to install other extensions, or can that be done with basic fluid extension?
In Fluid you have two ways to achieve this:
Prepare the desired data in the controller and assign it to the view as variable.
Create a custom viewhelper which contains the logic to build the desired data.
You can also combine these two and store the result of a viewhelper call in a variable using the f:variable viewhelper (more usage examples):
<f:variable name="myvariable">{acme:custom.viewhelper()}</f:variable>
In this specific case you can also install the VHS extension, the swiss army knife of Fluid, and use its UniqIdViewHelper Notice that you normally don't need this for forms since you bind them to (domain) objects you want to create/edit and let Extbase/Fluid handle the rest.
In Fabricator Assemble, I could have a component button.html:
<a class="button">{{text}}</a>
I can use this with the syntax {{>button text='Home'}}. Notably, I have to specify a name for the "text" attribute.
I'm looking to see how I can handle not needing to do that in Assemble. The Literals section of the docs for Handlebars (whiich Fabricator Assemble is built on) highlights an alternative syntax with which I could include a button:
{{>button 'Home'}}
In this example, "Home" is a value without any name for it at all. Handlebars also indicates the following is possible as a basic block:
{{#button}}
<b>Some button content</b>
{{/button}}
Likewise, that content has no name.
I'd like to be able to do this same thing in Fabricator Assemble, but it doesn't seem to have a way for me to include this nameless content. In templates there's {% body %} but that doesn't work here.
In Handlebars, which Fabricator Assemble is based on, all examples for how to recreate this involve JavaScript, which doesn't translate well to Assemble.
What can I do to use {{>button 'Some text'}} or {{#button}}...{{/button}} syntax in Fabricator Assemble? Is this behaviour even available?
In the current version, the easiest way to achieve this is with a custom helper.
Add the following to the helpers option in your gulpfile.js:
default: (value, defaultValue) => {
return value || defaultValue;
},
Then inside a handlebars template:
<div>
{{default varName 'default value'}}
</div>
I feel like I'm missing something obvious. In working with v0.6.0, the Readme indicates you can use:
{%= partial("partial-name") %}
However, these are just getting printed as plain text. Do I need to use a different engine if I want to have those tags parsed?
Assemble allows using different engines and the example that you have is using lodash with custom delimiters.
To use the default partials helper in handlebars do {{partial "partial-name"}}
I've got a Symfony2.0 form and am trying to add a textarea field, by setting the field type to textarea.
If I pick anything else - number, percentage or whatever - it renders correctly. However, my textareas are rendering as single-line textboxes.
Any ideas why this could be?
It turned out that the problem was with my form theming. This wasn't obvious, as I didn't have anything in my form_layout.twig about textareas.
However, I was specifying {% block text_row %} in there. It turned out that textarea field display was falling back to using text_row because I hadn't also included a definition for {% block textarea_row %}. Once I added the missing block, everything worked as expected.