codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
42 stars 24 forks source link

Haste `options_label` insert tag and inputvar extension #106

Closed xchs closed 7 years ago

xchs commented 7 years ago

I have tried to get the option label by passing the field value via inputvar extension:

{{options_label::1::{{post::foo}}}}

(foo denominates the field name of the corresponding select menu)

However, the insert tag above outputs only the value provided by the {{post::foo}} insert tag and not the option label previously selected in the form.

The same insert tag works perfectly fine in the Notification Center if {{post::foo}} gets replaced by the ##form_foo## simple token:

{{options_label::1::##form_foo##}}

[Tested with Contao 4.3.10]

qzminski commented 7 years ago

@aschempp @Toflar can we even support the nested insert tags? Or shall we provide the extra key for that insert tag, e.g. {{options_label::1::_post_foo}} ?

Toflar commented 7 years ago

Did anybody debug why it does not work? Sounds like a Core bug to me because nested insert tags should work.

xchs commented 7 years ago

Is the syntax of the nested insert tag correct? Or do I have to write three curly brackets?

{{{options_label::1::{{post::foo}}}}}
qzminski commented 7 years ago

I just tried the {{abbr::{{page::title}}}}Foobar{{abbr}} syntax and it does work in the frontend, so I assume two curly brackets are enough. @xchs can you check if a single {{post::foo}} outputs the correct data in the notification?

Also, why would you use the inputvar extension if that insert tag is provided by Contao out of the box? Maybe the problem is that the extension does not play well for some reason with haste or notification_center.

xchs commented 7 years ago

Thanks, Kamil.

can you check if a single {{post::foo}} outputs the correct data in the notification?

Yes. The single insert tag {{post::foo}} outputs the correct option value bar.

Also, why would you use the inputvar extension if that insert tag is provided by Contao out of the box?

Yes, my bad, sorry. I have only seen now that this insert tag is also present in the core. I have now removed the extension.

However, the initial problem remains:

aschempp commented 7 years ago

I didn't even know we can nest insert tags ^^

qzminski commented 7 years ago

Hmm I can't reproduce issue neither in the frontend nor in the notification_center. My notification content:

POST: {{post::foobar}}
OPTIONS LABEL: {{options_label::12::{{post::foobar}}}}

And the output:

POST: value_2
OPTIONS LABEL: Label 2

@xchs guess we would need to debug it on your system then.

qzminski commented 7 years ago

Just came to my mind – what is your exact field name and test value? Maybe it has something to do with the encoding.

xchs commented 7 years ago

@qzminski Thanks. I can give you access to my system if you want to reproduce it there. Can I contact you via email?

qzminski commented 7 years ago

Feel free, you can find my e-mail on my Github profile.

qzminski commented 7 years ago

Ok so the issue does not appear under Contao 3 but appears under Contao 4 and only in the production environment. The development seems to work fine. @aschempp @Toflar any ideas?

aschempp commented 7 years ago

Maybe related to AppCache and insert tags as ESI requests?

qzminski commented 7 years ago

This is the contao/core-bundle issue, see https://github.com/contao/core-bundle/issues/849