Global variable inside the Flux Form - typo3

I am using Typo3 6.2.14 and i want to declare the Global Variable Flux Form.
{namespace vt=FluidTYPO3\Vhs\ViewHelpers}
<f:section name="Main">
<vt:variable.set name="test" value="2" />
<vt:variable.set name="test" value="{vt:math.sum(a: test, fail: 2, b:2)}" />
</f:section>
I want to access "test" variable value Globally

We can Set and Get Global Variable inside Flux Form Using Register.
<v:variable.register.set name="counter" value="1" />
For Getting That Variable Value using.
<v:variable.register.get name="counter">
For More information SET and GET Variable

Related

uploading multiple images from the frontend using FAL in TYPO3 /extbase

I am using this Helhum example for uploading images from the frontend, which is located on the following link
https://github.com/helhum/upload_example
If we check its form fields in partial file on location
https://github.com/helhum/upload_example/blob/master/Resources/Private/Partials/Example/FormFields.html
there is given two uploads option which are following
{namespace h=Helhum\UploadExample\ViewHelpers}
<label for="title">
<f:translate key="tx_uploadexample_domain_model_example.title" /> <span class="required">(required)</span>
</label><br />
<f:form.textfield property="title" /><br />
<label for="image">
<f:translate key="tx_uploadexample_domain_model_example.image" />
</label><br />
<h:form.upload property="image" >
<f:if condition="{resource}">
<f:image image="{resource}" alt="" width="50"/>
</f:if>
</h:form.upload><br />
<label for="image_collection">
<f:translate key="tx_uploadexample_domain_model_example.image_collection" />
</label><br />
Here for the property="imageCollection.0" if I make it multiple="multiple" then it give me the following error
1297759968: Exception while property mapping at property path "imageCollection": PHP Warning: spl_object_hash() expects parameter 1
to be object, null given in
/var/www/webroot/typo3_src-7.6.14/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 155 (More information)
And if I remove the 0 and just try to click a botton then it even not generate a form and give me the following error
1297759968: Exception while property mapping at property path "": The source is not of type string, array, float, integer or boolean, but of
type "object" (More information)
So long story in short, how can I fix this example for multiple images uploading. I try to used without helper function just used a standerd fluid function <f:form:upload> it still give me a same error. please somebody can help me in sort out this problem.

Random image with v:iterator.random | cache issue

I try to output 1 random image with VHS (version 2.4.0) RandomViewHelper v:iterator.random.
This is my code:
{namespace flux=FluidTYPO3\Flux\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:layout name="Content" />
<f:section name="Configuration">
<flux:form id="random-image" label="Random Image" options="{icon: 'Icons/Content/Example.gif', group: 'Joya'}">
<flux:field.input name="classname" label="Classname" />
</flux:form>
<flux:form.section name="images" label="Images">
<flux:form.object name="image" label="Image">
<flux:field.file name="imagesrc" label="Image" allowed="png,jpg" maxItems="1" size="1" />
</flux:form.object>
</flux:form.section>
</f:section>
<f:section name="Preview">
Random Image
</f:section>
<f:section name="Main">
<div class="random-image">
<v:iterator.random as="img" subject="{images}">
{img.image.imagesrc}
</v:iterator.random>
</div>
</f:section>
I added 3 images to test, but it always outputs the same image.
Edit: the output of random is cached. So it outputs another image after the cache is cleared.
Can I disable the cache just for this line of code?
https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html
The solution is to use the VHS ViewHelper v:render.uncache and creatre a partial with the part that shall not be cached. Its not the best solution as you need an extra file. But right now the only other way I can think of is to use some Typoscript, and thats also something I want to avoid.
Another approach is to load the image true an ajax call, this way you can cache the page, but not the random image.

How to include a constant in a TYPO3 Fluid VHS menu

I have a simple menu generated by the Fluid Menu ViewHelper:
<v:page.menu useShortcutData="TRUE" levels="3" expandAll="1" class="menu" classActive="act" substElementUid="1" excludePages="12,13,3" />
There are multiple languages and each language has different pages hidden in the navigation that I would like to change in the "excludePages" part.
In Typoscript I would simply use a constants marker like {$exclude}. Adding the marker in fluid breaks the menu. What would be the way to achieve this in an inline Fluid setup like this?
There are different ways to get constant into Fluid.
1. Include form TypoScript
{f:cObject(typoscriptObjectPath: 'lib.myConstant')}
2. Save in settings from your ext.
plugin.tx_myext.settings {
myonstant = TEXT
myconstant = 1,2,3
}
3. Configuration in Page Template (the pure fluid way)
<f:section name="Configuration">
<flux:form id="mypage" options="{icon: 'Icons/Page/Standard.gif'}">
<flux:field.tree name="myConstantFromTRee" table="pages" parentField="pid" expandAll="0" multiple="1" minItems="0" maxItems="0" label="myConstantFromList" foreignLabel="title" size="10"/>
</flux:form>
<flux:grid>
<flux:grid.row>
<flux:grid.column colPos="0" name="main" />
</flux:grid.row>
</flux:grid>
</f:section>
And access it with {settings.myConstantFromTRee}.

FLUX configuration for a typolink

How can I use a typolink-field at my FLUX Flexform-Configuration (Backend)
<f:section name="Configuration">
<flux:form id="home" options="{icon: 'Icons/Content/myicon.gif', group: 'Homepage'}">
<flux:field.input name="txtHeadline" label="Headline" />
<!-- ?? -->
<flux:field.input name="lnkTarget" label="Link">
<flux:wizard.link />
</flux:field.input>
</flux:form>
</f:section>
Main Section:
{namespace v=Tx_Vhs_ViewHelpers}
...
<v:link.typolink parameter="{parameter: section.item.url}">Beautiful link</v:link.typolink>
<!-- or -->
<v:uri.typolink parameter="{parameter: section.item.url}" />
That's my first steps with FLUID Powered TYPO3 and I have no idea?
Thanks for your help. I need this input field and the link wizard for the 'normal' output: <a href="mylink" class="xy" />
Jost is right. You need to pass the value from the field to the TypoLink ViewHelper from VHS.
Being partially compatible with the TYPO3 CMS Core typolink function, you need to pass your field value as parameter.
Having a form field like:
<flux:field.input name="lnkTarget" label="Link">
<flux:wizard.link />
</flux:field.input>
Example with the plain contents of a field:
<v:link.typolink configuration="{parameter: lnkTarget}" />
Example with custom overrides/additions to the field value:
<v:link.typolink configuration="{parameter: lnkTarget, additionalParams: '&print=1', title: 'Follow the link'}">
Click Me!
</v:link.typolink>
Notice where I placed {lnkTarget}.
You can look those up in the DocComent Block on the ViewHelpers:
https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Link/TypolinkViewHelper.php#L22
https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Uri/TypolinkViewHelper.php#L22
Being one of the maintainers, if you need further feedback-please raise an issue on the Github project if you have problems using it or join us on IRC (#fedext on Freenode)
Now in 2021 (Typo3 10) use:
<flux:field.input name="linktarget" label="Link" config="{renderType: 'inputLink'}"></flux:field.input>
And
<f:link.typolink parameter="{parameter: d.job.linktarget}">Click Me!</f:link.typolink>

Overriding a label in Zend Fom config XML

Hi I am using an xml file of the following structure:
<?xml version="1.0"?>
<configdata>
<page>
<form action="" method="post">
<elements>
<page_title type="text" name="page_title" >
<options label="Page Title" required="true" />
</page_title>
<page_content type="textarea" name="page_content">
<options label="Page Content" />
</page_content>
</elements>
</form>
</page>
I have two forms which take exactly the same data, but I need to change the labels on the form. I would rather not just cut and paste the code contained within <page></page> and adjust the labels. Is there a way I can 'extend' page and set the labels that way?
you should be able to do it right from the controller (i know it works with normal Zend_form objects)
$form = new Your_Form_Here();
$form->Elementname->setLabel('new label');
That's all there is to it. You may have to make some adjustments because you're using a config file but it should'nt be to hard.