Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Today 09:33:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,317
Website GitHub

Showing custom labels in a com_connect email using the body_form?

I have a membership signup form using com_connect (v4.9 branch) and txp 4.9.1 that has a few optional blocks, radio options and checkboxes. I’m trying to give the recipients a clean output using a body_form with a text-only and html part. That all works nicely enough, but I’m having the weirdest problems providing custom labels for the radio buttons and checkboxes.

First of all, the regular text inputs and textareas that have a label attribute all show up fine. As the radios have a group rather than a label and checkboxes (and a few special cases) are handled differently, I get my barebones name attribute in the output. I wanted to make that cleaner.

Here’s the relevant part of the body form (slightly simplified):

<table>
<txp:com_connect_fields break="tr">
    <td >
        <txp:evaluate test="com_connect_if">
        <txp:com_connect_if name="mitgliedstyp">Art der Mitgliedschaft</txp:com_connect_if>
        <txp:com_connect_if name="dateOfBirth">Geburtsdatum</txp:com_connect_if>
        <txp:com_connect_if name="amount">Beitrag</txp:com_connect_if>
        <txp:com_connect_if name="paymentMethod">Zahlungsmethode</txp:com_connect_if>
        <txp:com_connect_if name="zahlungsinterval">Zahlungsinterval</txp:com_connect_if>
        <txp:com_connect_if name="newsletter">Newsletter</txp:com_connect_if>
        <txp:com_connect_if name="zahlungsinterval">Datenverarbeitung</txp:com_connect_if>
        <txp:else />
        <txp:com_connect_label />
        </txp:evaluate>
    </td>
    <td>
        <txp:evaluate test="com_connect_if">
        <txp:com_connect_if name="mitgliedstyp" value="mitglied_voll">Mitglied</txp:com_connect_if>
        <txp:com_connect_if name="mitgliedstyp" value="mitglied_foerder">Fördermitglied</txp:com_connect_if>
        <txp:com_connect_if name="amount"><txp:com_connect_value /> €</txp:com_connect_if>
        <txp:com_connect_if name="paymentMethod" value="bank_ueberweisung">Überweisung</txp:com_connect_if>
        <txp:com_connect_if name="paymentMethod" value="bank_lastschrift">Lastschrift</txp:com_connect_if>
        <txp:com_connect_if name="zahlungsinterval" value="lastschrift_monatlich">Monatlich</txp:com_connect_if>
        <txp:com_connect_if name="zahlungsinterval" value="lastschrift_halbjaehrlich">Halbjährlich</txp:com_connect_if>
        <txp:else />
        <txp:com_connect_value />
        </txp:evaluate>
    </td>
</txp:com_connect_fields>
</table>

I’ve also tried this with populating a variable and then outputting either the variable or the regular internal label, (resetting it for each loop) e.g.:

<table>
<txp:com_connect_fields break="tr">
    <td>
        <txp:variable name="antrag_label" value="" />
        <txp:variable name="antrag_label" trim>
            <txp:com_connect_if name="mitgliedstyp">Art der Mitgliedschaft</txp:com_connect_if>
            <txp:com_connect_if name="dateOfBirth">Geburtsdatum</txp:com_connect_if>
            <txp:com_connect_if name="amount">Beitrag</txp:com_connect_if>
            <txp:com_connect_if name="paymentMethod">Zahlungsmethode</txp:com_connect_if>
            <txp:com_connect_if name="zahlungsinterval">Zahlungsinterval</txp:com_connect_if>
            <txp:com_connect_if name="newsletter">Newsletter</txp:com_connect_if>
            <txp:com_connect_if name="zahlungsinterval">Datenverarbeitung</txp:com_connect_if>
        </txp:variable>
        <txp:if_variable name="antrag_label" value="">
            <txp:com_connect_label />
        <txp:else />
            <txp:variable name="antrag_label" />
        </txp:if_variable>
    </td>
    <!-- analogue for com_connect_value -->
</txp:com_connect_fields>
</table>

Whatever I try, I get output like this in my email (excerpt):

(and so on…). The details marked in bold in the right-hand column are the actual values supplied in the form.

How can I get just the relevant item’s label to show in each case, rather than getting them all in every field?

Perhaps I’m wrongly assuming that txp:com_connect_fields loops like article_custom?

Do I have to write out each table line with a special case individually and then loop over only the relevant items with regular labels using the <txp:com_connect_fields name="field, names, here">…</txp:com_connect_fields> where appropriate?

EDIT: FWIW, this is what it looks like when output as a regular list without any com_connect_if tags:


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB