[TYPO3-english] How to add ViewHelper in Powermail ext. TYPO3 v. 6.2.2

Thomas Petersen tp at codem.dk
Tue May 20 08:35:06 CEST 2014


Hi.

I'm trying to add a dateNow to a field in Powermail as a booking ID.
But I can't get it to work.

This is what I have tried..
Okay so I have the folder /www/typo3conf/ext/powermail/Classes/ViewHelpers
In that folder I have a file called BookIdViewHelper.php with this code

<?php
#Booking ID
class BookIdViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
    /**
     * Renders time()
     *
     * @return int The current timestamp
     */
    public function render() {
        return time();
    }
}

Then on a page that link to my powermail form page i have this link
<a href="http://www.domain.dk/?id=47&tx_powermail_pi1[field][30]={urs:time()}">
(urs:time() is the date and I want to place that date into the powermail field=30)

Then I have the powermail fluid template /www/typo3conf/ext/powermail/Resources/Private/Templates/Forms in the form.html file I added the namespace like this and have added an extra  {urs.time()} to the H3-tag so the date should be showed in the H#-tag and in powermail field 30. 

{namespace vh=Tx_Powermail_ViewHelpers}
{namespace urs=Tx_Powermail_ViewHelpers}
<f:layout name="Default" />

Render Powermail Form
{forms}             All Forms with their Pages and their Fields


<f:section name="main">

    <f:flashMessages class="powermail_message powermail_message_error" />

    <f:if condition="{forms}">
        <f:then>
            <f:for each="{forms}" as="form">
                <f:form
                        action="{action}"
                        controller="Forms"
                        enctype="multipart/form-data"
                        class="powermail_form powermail_form_{form.uid} {form.css} {vh:Misc.MorestepClass(activate: '{settings.main.moresteps}', class: 'powermail_morestep')}">
                    <h3>{form.title} - {urs.time()}</h3>
                    <f:render partial="FormError" arguments="{error}" />

                    <f:for each="{form.pages}" as="page">
                        <fieldset class="powermail_fieldset powermail_fieldset_{page.uid} {page.css}">
                            <legend class="powermail_legend">{page.title}</legend>
                            <f:for each="{page.fields}" as="field">
                                <f:render partial="Forms/{vh:String.Upper(string: '{field.type}')}" arguments="{field: field}" />
                            </f:for>
                        </fieldset>
                    </f:for>

                    <f:form.hidden name="form" value="{form.uid}" />
                    <f:render partial="HoneyPod" arguments="{form: form}" />
                </f:form>
            </f:for>
        </f:then>
        <f:else>
            <f:translate key="error_no_form" />
        </f:else>
    </f:if>
 
But its not working.. im only getting the text {urs:time()} in the field and after the H3-tag, so no date..

What have I missed ?


More information about the TYPO3-english mailing list