Keycloak display different text in theme - jboss

I'm customizing the keycloak theme but want to display a different text in the template.ftl based on the current page.
How can I achieve that in the freemarker template - template.ftl, something like this
<#if login>
...
</#if>
<#if register>
...
</#if>

Okay, figured it out...not a big deal to do
<#if register??>
<li>Sign In</li>
<#else>
<li>${msg("doRegister")}</li>
</#if>

Related

How can I inject a Vuetify form from a database into a template?

Apologies if this has been answered elsewhere, I have searched but not found anything as of yet.
I have a v-form stored in a database that I wish to pull back and display on a page. However, when I do so the form is not being rendered correctly. It remains as Vuetify template code and is not converted to HTML.
The form looks like this:
<v-form>
<v-container>
<v-row>
<v-col>
<div class="text-h4">Form 1</div>
</v-col>
</v-row>
<v-row>
<v-col
cols="12"
md="6"
>
<v-text-field
:counter="255"
label="Customer ID"
required
></v-text-field>
</v-col>
<v-col
cols="12"
md="6"
>
<v-text-field
label="Amount"
></v-text-field>
</v-col>
<v-col class="text-right">
<v-btn
#click="submitForm"
>
Submit
</v-btn>
</v-col>
</v-row>
</v-container>
</v-form>
I did come across a render function, but I've either not used it correctly or it is not have the desired effect - I'm a newbie at this so it may well be something simple!
The above form is pulled back from the database using axios, and the request happens in the created() function on the page where I wish to display it, using mapGetters() to grab it from the store and v-html in a v-card to show it.
Any help on this would be much appreciated.
Thanks for your time people!
How can I inject a Vuetify form from a database into a template?
You can't.
v-html docs
Updates the element’s innerHTML. Note that the contents are inserted as plain HTML - they will not be compiled as Vue templates. If you find yourself trying to compose templates using v-html, try to rethink the solution by using components instead
Another note from docs
Note that you cannot use v-html to compose template partials, because Vue is not a string-based templating engine. Instead, components are preferred as the fundamental unit for UI reuse and composition.
So in short, you cannot insert any partial template into a template of a component at runtime.
But you can create component at runtime and use it as dynamic component
const vm = new Vue({
el: '#app',
data() {
return {
downloadedTemplate: '<div> Hello </div>', // pretend this was downloaded from the server
}
},
computed: {
myDynamicComponent() {
return Vue.component('myDynamicComponent', {
template: this.downloadedTemplate
})
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<component :is="myDynamicComponent" />
</div>
Note that to do this, you must use Vue distribution which includes the template compiler
I don`t know about your particular use case, but unless you are working with tens of different forms, storing templates in database sounds like a sub-optimal strategy - a lot of unnecessary work and hard to mainain

How to implement multilingual labels in tx:mask (TYPO3)?

I would like implement multilingual labels in TYPO3 mask. After implementing with the following FLUID-code the label does not change based on the chosen language:
<f:link.page pageUid="{data.tx_mask_inhalt_text_link}">
<f:if condition="{TSFE.sys_language_uid} == 1">
<f:then>
enter code here`Read more
</f:then>
<f:else>
Weiterlesen
</f:else>
</f:if>
</f:link.page>
I solved the issue with:
MASK-Template:
<f:translate key="label" />
TYPO3-Setup:
plugin.tx_mask._LOCAL_LANG.de.label = Weiterlesen
plugin.tx_mask._LOCAL_LANG.en.label = Read more
Works like a charm.
You can use XLIFF files to localize values in TYPO3. This is neither limited to nor different for mask templates (as these are common Fluid templates).
A locallang.xlf contains entries like:
<trans-unit id="readmore">
<source>Read more</source>
<target>weiterlesen</target>
</trans-unit>
In the HTML template you can use the f:translate viewhelper:
<f:translate key="LLL:EXT:your_extension/Resources/Private/Language/locallang.xlf:readmore" />
This will render the value depending on the current frontend language.
This is the usual way of translating in TYPO3. Please refer to these official documentations for all details:
XLIFF | TYPO3 documentation
f:translate | Fluid guide

TYPO3 - how to properly define constant, store it into variable and use inside of fluid template

In the Fluid template of plugin I am working on, some things are hardcoded. For instance:
<f:else>
<li>
<v:page.link pageUid="114" />
</li>
</f:else>
Since pageUid values are not same on test and production server I would like to make this more dynamic.
I would like to store this somehow in variable and then use the variable in the fluid template.
I just dont know hot to make this and where in TYPO3.
Thanks in advance!
Because it is an setting do it like this:
Constants:
plugin.myext.settings.detailPid = 123
Setup:
plugin.myext.settings.detailPid = {$plugin.myext.settings.detailPid}
Variables are for variable content. If you have the same PID using variables with TEXT or similiar is overdressed and settings are the correct way.
Also variables are only accessable for FLUID_TEMPLATE content element, not for plugins!
Also in your extbase controller you can access these settings by simple access $this->settings['detailPid']without to render the cObjects first.
In your fluid you can access settings by {settings.detailPid}.
In typoscript template for your content object FLUIDTEMPLATE:
Typoscript setup/configuration:
10 = FLUIDTEMPLATE
10 {
variables {
pageUid = TEXT
pageUid.value = 114
}
}
or using constants
Typoscript constants:
pageUid = 114
Typoscript setup/configuration:
10 = FLUIDTEMPLATE
10 {
variables {
pageUid = TEXT
pageUid.value = {$pageUid}
}
}
Then you can fetch pageUid in your Fluid HTML
<f:else>
<li>
<v:page.link pageUid="{pageUid}" />
</li>
</f:else>
To use variables in a Fluid partial, make sure to pass these along, e.g. by providing _all:
<f:render partial="fluid_part_header" arguments="{_all}" />
If you use EXT:vhs anyways, you can do the following to:
TS-Constants:
pageUid=114
TS-Setup:
settings.pageUid = {$pageUid}
Template (Fluid)
<f:else>
<li>
<v:page.link pageUid="{v:variable.typoscript(path: 'settings.pageUid')}" />
</li>
</f:else>
This will make it available for all FLUID Templates.
Please consider using jokumer's solution.
randomresult's solution would work, but I wouldn't suggest it. You don't need vhs to pass variables.
Not talking about Paul Beck`s solution, because it wouldn't work at all. Not anymore at least. (See TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper, https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/CObject.html). It accepts only content objects.
Set your Pid in constants like PID_SOME_PAGE = 123 and set a variable in your plugins settings. Like this:
plugin.tx_yourplugin {
...
settings{
somePage = {$PID_SOME_PAGE}
}
...
}
You can bypass that constants version if you want and set your page id in settings directly. It's just a cleaner way in my opinion, especially for larger websites.
Then you can use that variable in your template, like this <f:link.page pageUid="{settings.somePage}">Go to Page</f:link.page>. More options for f:link.page here: https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Link/Page.html

Hi, Does anyone knows how to create the automatic sitemap in liferay

I have created the sitemp.xml manually.But now I want to create the automatic sitemap in liferay.
Does anyone knows how to create the automatic sitemap in liferay?
You should
Go to content -> configuration -> Application Display Templates
Write template either in velocity or freemarker
Use site map portlet on your custom page and configure it, using your created custom template.
Here is example of mine:
<div>
<h1>Map service</h1>
<#assign firstLevelCounter=0>
<#list entries as secondLvlLayout>
<#if !secondLvlLayout.isHidden()>
<#if (firstLevelCounter+1)%2==0>
<div>
</#if>
<div>
<div><h2>${secondLvlLayout.getName(locale)}</h2></div>
<#list secondLvlLayout.getChildren() as thirdLvlLayout>
<div>
<div>
<h3>${thirdLvlLayout.getName(locale)}</h3>
</div>
<#if thirdLvlLayout.getChildren()?has_content>
<ul>
<#list thirdLvlLayout.getChildren() as forthLvlLayout>
<li>
<div><span>${forthLvlLayout.getName(locale)}</span></div>
</li>
</#list>
</ul>
</#if>
</div>
</#list>
</div>
<#if (firstLevelCounter+1)%2==0>
</div><hr/>
</#if>
<#assign firstLevelCounter=firstLevelCounter+1>
</#if>
</#list>
</div>

theme div on user register / user login form

where is this nested div construction defined, that the user-login form doesnt has:
<div class="form-item form-type-password form-item-pass-pass1 password-parent">
<div>
<input>Password Input</input>
<div>Password Strength</div>
</div>
<div>
<input>Password Confirm</input>
</div>
i have looked in form.inc, the user-module folder but no luck. as stated, the user-login form is printed plain without any nesting like this, so where is this determination done?
This is added with js. Look into ROOT/modules/user/user.js for the code.