typo3typo3-7.6.xtypolink

v:link:typolink with aditionalParams to set language via flux.field.select


I try to create a Content Element to create links to other languages. I think this is possible with just a content element and I do not need a own view helper for this.

What I have so far:

{namespace flux=FluidTYPO3\Flux\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}

    <f:layout name="Content" />

    <f:section name="Configuration">
        <flux:form id="landingpage-language" label="Landingpage Language" options="{icon: 'Icons/Content/Example.gif', group: 'My Ele'}">
            <flux:field.input name="title" label="Title"/>
        </flux:form>
        <flux:form.section name="languages" label="Languages">
            <flux:form.object name="language" label="Language">
                <flux:field.input name="languagename" label="Language Visible Name"/>
                <flux:field.select name="language" label="System Language" items="{
                           0:{0:'English',1:'&L=1'},
                           1:{0:'German',1:'&L=2'}
                           }" />
                <flux:field.input name="url" label="URL">
                    <flux:wizard.link/>
                </flux:field.input>
            </flux:form.object>
        </flux:form.section>
    </f:section>

    <f:section name="Preview">
        Preview
    </f:section>

    <f:section name="Main">
        <h2>{title}</h2>
        <ul  class="languages">
            <f:for each="{languages}" as="langele"> 
                <li><v:link.typolink configuration="{parameter: langele.language.url, additionalParams: langele.language.language}">{langele.language.languagename} {langele.language.language}</v:link.typolink></li>
            </f:for>
        </ul>
    </f:section>

This works but I have 2 problems I can't solve yet:

1. additionalParams

Right now the select items have the values like &L=1. I had to do it this way cause I was not able to add the &L= directly in the typolink configuration. What I would like to have is something like that:

<v:link.typolink configuration="{parameter: langele.language.url, additionalParams: '&L='langele.language.language}">

With this I could have just the ID in the select-items. Is this possible and if so, how?

2. select items Query

The documentation says it is possible to fill the items of the flux:field.select with a query. But I can not find any example. What I would like to have is all the languages configured in typo3 in this select-box. Is this possible and if so, how?


Solution

  • something correction in fluxform:

    <flux:field.select name="language" label="System Language" 
    items="{1:'English',2:'German'}" />
    

    you can use fluid typolink instead of vhs viewhelper

    <f:for each="{languages}" as="langele"> 
         <li><f:link.typolink parameter="{langele.language.url}" additionalParams="&L={langele.language.language}">{langele.language.languagename} {langele.language.language}</f:link.typolink></li>
    </f:for>
    

    But as per your need, I suggest to you use fluid page link:

    <f:for each="{languages}" as="langele">
        <li><f:link.page pageUid="{langele.language.url}" additionalParams="{L:'{langele.language.language}'}">{langele.language.languagename} {langele.language.language}</f:link.page></li>
    </f:for>