Access tx_fed_page_flexform in fluidtemplate - typo3

This question is related to Access fluidpage configuration in template.
I try the same as in the question above. But as flux:flexformis outdated and replaced with flux:form there may be some changes I'm not aware of.
With the following code I try to access the flex:form.fields from the menu-items:
<v:page.menu levels="1" as="sections">
<ul class="main-navi">
<f:for each="{sections}" as="section" iteration="iteration">
<f:debug>{section}</f:debug>
<flux:form.data table="pages" field="tx_fed_page_flexform" uid="{section.uid}" as="sectionData" />
<f:debug>{sectionData}</f:debug>
<li {f:if(condition: section.active, then: ' class="active"')}>
<f:link.page pageUid="{section.uid}" title="{section.linktext}">{ section.title}</f:link.page>
<div class="testmenu"></div>
</li>
</f:for>
</ul>
</v:page.menu>
In the Debug of the section (<f:debug>{section}</f:debug>) I see the value of tx_fed_page_flexform:
tx_fed_page_flexform => '<?xml version="1.0" encoding="utf-8" standalone="
;yes" ?> <T3FlexForms> <data> <sheet inde
x="options"> <language index="lDEF">
; <field index="text"> &
lt;value index="vDEF">test1234</value> &l
t;/field> </language> </sheet> </d
ata> </T3FlexForms>' (336 chars)
The value I search is test1234.
But when I debug the sectionData (<f:debug>{sectionData}</f:debug>) I just get a NULL.

Found a solution. To set sectionData use v:variable.set. the as in flux:form.data seems not to work.
<v:variable.set name="sectionData" value="{flux:form.data(table:'pages', field:'tx_fed_page_flexform', uid:'{section.uid}')}" />

Related

Dynamic Elements

Is there a way to dynamically create elements in fluid like so:
<f:section name="foo">
<{tag} />
</f:section>
what should be used somewhere like that:
<f:render section="foo" arguments="{ tag: 'f:form.textfield' }" />
what should result in output, containg: <input type="text" … />, not <f:form.textfield … /> as it does.
Not like that, but you could do something with f:switch:
<f:section name="foo">
<f:switch expression={tag}>
<f:case value="f:form.textfield"><f:form.textfield /></f:case>
<f:case value="etc">...</f:case>
</f:switch>
</f:section>

Magento Checkout Comment

i'm still a beginner at Magento and try to learn how to create Modules. Right now i'm working on a module, which allows the customer to add a comment during the checkout.
Now i got a problem to implement the textarea, i created a new file called "practice" under app/design/frontend/base/default/layout and under app/design/frontend/base/default/template. I upload the new layout-file in the config.xml file of my module. But there isnt any textarea during the checkout, even though the right template is uploaded (i activated the template path hint option to see the path of each Block).
app/code/local/Practice/CheckoutComments/etc/config.xml
<frontend>
<layout>
<updates>
<checkoutcomments>
<file>practice/checkoutcomments.xml</file>
</checkoutcomments>
</updates>
</layout>
</frontend>
Here is the code of the layout.xml file and the phtml.file i override:
app/design/frontend/base/default/layout/practice/checkoutcomments.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<checkout_onepage_review translate="label">
<reference name="checkout.onepage.agreements">
<action method="setTemplate">
<template>practice/checkoutcomments/onepage/comment-agreements.phtml
</template>
</action>
</reference>
</checkout_onepage_review>
</layout>
app/design/frontend/base/default/template/practice/checkoutcomments/onepage/comment-agreements.phtml
<?php
/**
*
* #see Mage_Checkout_Block_Agreements
*/
?>
<!-- Start of CheckoutComments module code -->
<form action="" id="checkout-agreements" onsubmit="return false;">
<ol class="checkout-agreements">
<div>
<br /> <label for="checkoutcomments"><?php echo Mage::helper('core')->__('Add your Comment for this Order') ?></label>
<textarea name="checkoutcomments" id="checkoutcomments"
style="width: 450px; height: 100px;"></textarea>
</div>
<!-- End of CheckoutComment module -->
<?php if ($this->getAgreements()) : ?>
<?php foreach ($this->getAgreements() as $_a): ?>
<li>
<div class="agreement-content"
<?php echo ($_a->getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>>
<?php if ($_a->getIsHtml()):?>
<?php echo $_a->getContent()?>
<?php else:?>
<?php echo nl2br($this->escapeHtml($_a->getContent()))?>
<?php endif; ?>
</div>
<p class="agree">
<input type="checkbox" id="agreement-<?php echo $_a->getId()?>"
name="agreement[<?php echo $_a->getId()?>]" value="1"
title="<?php echo $this->escapeHtml($_a->getCheckboxText()) ?>"
class="checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->escapeHtml($_a->getCheckboxText()) ?></label>
</p>
</li>
<?php endforeach ?>
<?php endif; ?>
</ol>
</form>
I deactivated my module and overrode the code of app/design/frontend/base/default/template/checkout/onepage/agreements.phtml with my customized pthml.file from above, then the textarea appears! I guess that something is wrong with my configurationsfiles, but i reference to the right block, since the block is uploaded but there isnt any textarea.
I hope you can help me
Regards
I solved the question by accident:
In
app/design/frontend/base/default/layout/practice/checkoutcomments.xml
i changed the line
<template>practice/checkoutcomments/onepage/comment-agreements.phtml
</template>
to:
<template>practice/checkoutcomments/onepage/comment-agreements.phtml</template>
it seems that i choose a wrong autoformat in eclipse, but i'm wondering, that this makes such a huge difference
Regards

Typo3 Fluid - How do I check if two or more colPos have content and then print HTML

I want to print the following HTML only if one or more of the colPos has content in it. If none have content elements in it, then I don't want to print this block (the whole "row") of HTML.
<div class="row">
<div class="col-sm-4">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="5" />
</div>
<div class="col-sm-4">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="6" />
</div>
<div class="col-sm-4">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="7" />
</div>
</div>
I thought about getting the colPos and try to do a OR condition on Fluid. But I have no idea on how to do it. I know I can check one by one like this:
<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.dynamicContent', data: '5')}">
...HTML for colPos 5 HERE...
</f:if>
But I don't want to do that. In my template I have almost 50 different colPos and they are organized by blocks (rows). Like colPos 1 to 5 is one block(row). colPos 10 to 25 in another block(row). But some pages will not use some blocks (rows) of colPos, so there's no reason on printing the HTML code for those blocks (rows) of colPos unused.
Thanks for your help!
A fluid-only solution would be to assign the results of the <f:cObject>-ViewHelpers each to a variable, and then use the concatenation of these variables in a condition. The v:-namespace in the example is the namespace of the extension vhs:
<v:variable.set name="col-5" value="{f:cObject(typoscriptObjectPath: 'lib.dynamicContent', data: '5')}"/>
<v:variable.set name="col-6" value="{f:cObject(typoscriptObjectPath: 'lib.dynamicContent', data: '6')}"/>
<v:variable.set name="col-7" value="{f:cObject(typoscriptObjectPath: 'lib.dynamicContent', data: '7')}"/>
<f:if condition="{col-5}{col-6}{col-7}">
<div class="row">
<div class="col-sm-4">{col-5}</div>
<div class="col-sm-4">{col-6}</div>
<div class="col-sm-4">{col-7}</div>
</div>
</f:if>
You should of course move this stuff to a partial, which gets an array of the columns to print as a parameter. Then you need to write the logic only once.
Also, you should think again, if you really need 25 columns.
Since TYPO3 8.6, this is possible without extension "vhs":
<f:variable name="col-5">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="5" />
</f:variable>
<f:if condition="{col-5}">
<f:format.raw>{col-5}</f:format.raw>
</f:if>

How to render a parent and child active in a menu if they have the same URI and using Zend_Navigation?

Hello I'm digging into this problem without finding a solution. It seems very simple but I turn around for a while.
I'm trying to highlight a parent and 1 child in a menu. Both have the same uri, but only the parent is getting the active class.
Here my xml:
<configData>
<apps>
<agenda>
<label>Agenda</label>
<uri>/apps/agenda</uri>
<pages>
<page1>
<label>Page 1</label>
<uri>/apps/agenda</uri>
</page1>
<page2>
<label>Page 2</label>
<uri>/apps/agenda/page2</uri>
</page2>
</pages>
</agenda>
</apps>
</configData>
here my .phtml:
<div>
<?php echo $this->navigation(Zend_Registry::get('Zend_NavigationApp'))->menu()
->renderMenu(null, array(
'minDepth' => null,
'maxDepth' => 1,
'ulClass' => 'navigation',
'onlyActiveBranch' => false));
?>
</div>
and here the generated html:
<div>
<ul class="navigation">
<li class="active">
Agenda
<ul>
<li> /*Here the expected active class*/
Page 1
</li>
<li>
Page 2
</li>
</ul>
</li>
</ul>
</div>
All that I want to do is to get the "li" parent and "li" child with an active class after I clicked the parent link.
Solution
Using MVC instead of URI style config xml file fixed all my problems.
Here my fixed xml:
<configData>
<apps>
<agenda>
<label>Agenda</label>
<module>module_1</module>
<controller>control_1</controller>
<action>action_1</action>
<route>agenda_1</route>
<pages>
<page1>
<label>Page 1</label>
<module>module_1</module>
<controller>control_1</controller>
<action>action_1</action>
<route>agenda_1</route>
</page1>
<page2>
<label>Page 2</label>
<module>module_2</module>
<controller>control_2</controller>
<action>action_2</action>
<route>agenda_2</route>
</page2>
</pages>
</agenda>
</apps>
</configData>
Note that I'm using route definition in my ini file.

how to attribute to navigation (<ul><li>) from an xml source navigation

HI,
my xml file is as follows
<?xml version="1.0"?>
<config>
<nav>
<home>
<label>HOME</label>
<controller>index</controller>
<action>index</action>
</home>
<aboutus>
<label>ABOUT US</label>
<controller>about-us</controller>
<action>index</action>
</aboutus>
<destination>
<label>DESTINATION</label>
<controller>destination</controller>
<action>index</action>
</destination>
</nav>
</config>
for code in my layout.phtml file
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/clientnav.xml', 'nav');
$container = new Zend_Navigation($config);
$this->navigation()->setContainer($container);
echo $this->navigation();
i get the result
<ul class="navigation">
<li class="active">
HOME
</li>
<li>
ABOUT US
</li>
</ul>
but i want the result
<ul class="navigation">
<li class="active">
HOME
</li>
<li classs="sep"></li>
<li>
ABOUT US
</li>
</ul>
Note the separator between two list. Help me out.
If you HAVE to have the sep there and you cannot amend your CSS as #trickwallett suggested then you can query the navigation directly and then iterate over it yourself. Note that if you do this you will need to apply your own ACL rules.
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
$container = new Zend_Navigation($config);
$pages = $this->navigation($container)->findAllById("main");
foreach ($pages as $i => $page)
{
if(!$page->getVisible())
continue;
echo $this->menu()->htmlify($page);
}
There I use findAllById() but there are many others documented here