Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-09-22 21:50:35

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Using txp:variable to transfer data to a ZCR contact form

I am building a single page site to sell a small number of individual items. I present thumbnail images of the items, all articles in a ‘forsale’ section on the single page using a txp:article_custom tag, each image linked to a modal window bearing a larger version of the image with some text and a ‘call to action’ button inviting the site visitor to contact the seller about the specific item for sale described therein. This modal is populated by an AJAX call to mysalessite.com/forsale/theitemname (theitemname = the article title describing the item in the ‘forsale’ section).

The button on the ‘sales item’ modal opens up a second modal and closes the original. This second modal is populated by an AJAX call to mysalessite.com/contact
that bears a simple ZCR contact form in an iframe with source mysalessite.com/contact-ajax.

I set <txp:variable name="salesitem" value='<txp:title />' in the sales item modal and that works fine. However, the variable doesn’t return a result when I call it in the second modal (the contact form) where I want it to identify the item being queried. I am not a great coder and use Zurb Foundation 5 to build the site along with Textpattern. The modals and the ajax are more or less straight out of the Foundation 5 box.

I do get it that the first modal is in a TXP article environment and the second is not but nevertheless I can’t figure out how to achieve what I want, can anyone advise please.?

Last edited by joebaich (2014-09-26 04:15:56)

Offline

#2 2014-09-22 22:32:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Using txp:variable to transfer data to a ZCR contact form

joebaich wrote #284073:

I do get it that the first modal is in a TXP article environment and the second is not

Not sure if this is possible (I’m not good with modals so I’ll probably overlook something) but isn’t there a way to keep the code for the second modal in the individual article context? In other words, in the article form or inside the article tags that display the main article?

Offline

#3 2014-09-23 01:20:20

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Using txp:variable to transfer data to a ZCR contact form

Els wrote #284077:

Not sure if this is possible (I’m not good with modals so I’ll probably overlook something) but isn’t there a way to keep the code for the second modal in the individual article context? In other words, in the article form or inside the article tags that display the main article?

Hello Els, I had tried to come up with of a way of doing exactly that but haven’t found one. ZCR and the Foundation Reveal Modal with AJAX are simple to use at a basic level and I think you have encouraged me to try again along those lines.

Last edited by joebaich (2014-09-23 01:22:09)

Offline

#4 2014-09-23 07:48:43

springworks
Member
Registered: 2005-01-06
Posts: 172
Website

Re: Using txp:variable to transfer data to a ZCR contact form

How about adding another URL segment to the contact AJAX URL that identifies the article it is associated with? (In the same way that you have done it for the first modal.)

Offline

#5 2014-09-23 19:43:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Using txp:variable to transfer data to a ZCR contact form

Just guessing here, but the problem may lie with the iframe in the second modal. In essence that’s a separate page and the variable is not passed ‘through the iframe’ to it. springwork’s idea of passing a variable (such as the article id) to your contact form via the url you use to call the contact page iframe e.g. mysalessite.com/contact-ajax?salesid=123 sounds good. You can then retrieve that urlvar in your contact form zcr and repopulate it accordingly.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2014-09-24 16:30:38

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Using txp:variable to transfer data to a ZCR contact form

springworks wrote #284101:

How about adding another URL segment to the contact AJAX URL that identifies the article it is associated with? (In the same way that you have done it for the first modal.)

jakob wrote #284137:

Just guessing here, but the problem may lie with the iframe in the second modal. In essence that’s a separate page and the variable is not passed ‘through the iframe’ to it. springwork’s idea of passing a variable (such as the article id) to your contact form via the url you use to call the contact page iframe e.g. mysalessite.com/contact-ajax?salesid=123 sounds good. You can then retrieve that urlvar in your contact form zcr and repopulate it accordingly.

Thanks to you both, I am grateful. It does sound feasible and I’ll have a look at doing that.

Offline

#7 2014-09-26 05:35:47

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Using txp:variable to transfer data to a ZCR contact form

Thanks once again Springworks and Jakob. That did it for me. All I had to do was set a txp tag based url var in the first modal (it’s in the article context) on the call to action link and echo it into a suitable heading in the ‘Contact’ section page above the iFrame bearing the contact-ajax page.

Offline

#8 2014-12-19 01:40:23

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Using txp:variable to transfer data to a ZCR contact form

joebaich wrote #284073:

I set <txp:variable name="salesitem" value='<txp:title />' in the sales item modal and that works fine. However, the variable doesn’t return a result when I call it in the second modal (the contact form) where I want it to identify the item being queried. I am not a great coder and use Zurb Foundation 5 to build the site along with Textpattern. The modals and the ajax are more or less straight out of the Foundation 5 box.

Is it possible to look at the site to see how you managed that? I am struggling with a similar thing.

Last edited by admi (2014-12-19 01:48:30)

Offline

#9 2014-12-19 05:41:49

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Using txp:variable to transfer data to a ZCR contact form

admi wrote #286706:

Is it possible to look at the site to see how you managed that? I am struggling with a similar thing.

Hello Admi,

You can see the site here. It’s not finished and waits for some content input from the site’s owner. The modals on ‘the cars for sale’ work fine though thanks to the good advice received from Jakob and Springworks

Have a look and see if you can narrow down where you are struggling . I can’t give you access to the code on the site itself but will happily post relevant extracts with explanatory notes.

Offline

#10 2014-12-19 09:54:46

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Using txp:variable to transfer data to a ZCR contact form

jakob wrote #284137:

Just guessing here, but the problem may lie with the iframe in the second modal. In essence that’s a separate page and the variable is not passed ‘through the iframe’ to it. springwork’s idea of passing a variable (such as the article id) to your contact form via the url you use to call the contact page iframe e.g. mysalessite.com/contact-ajax?salesid=123 sounds good. You can then retrieve that urlvar in your contact form zcr and repopulate it accordingly.

I use iframe for pop-up modal ZCR conact form –

<a href="<txp:site_url />contact?keepThis=true&TB_iframe=true&height=300&width=350" title="" class="thickbox read-more button mobile-small">Ask a question...</a>  

what do I have to add to the url so that a message would show the article url or title?

Offline

#11 2014-12-19 15:13:45

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Using txp:variable to transfer data to a ZCR contact form

Use the plugin txp:adi_gps to manage your URL variable on the site and assign it to a <txp:variable/>. Add the URL variable constructed with something appropriate e.g <txp:title/> to your Thickbox/ZCR call and add the <txp:variable/> containing the relevant article title text into the ZCR form title field.

Sorry if that’s a little rushed, I am setting off on a long journey early tomorrow and have much to do before then.

Offline

#12 2014-12-19 15:40:37

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Using txp:variable to transfer data to a ZCR contact form

joebaich wrote #286711:

Hello Admi,

You can see the site here. It’s not finished and waits for some content input from the site’s owner. The modals on ‘the cars for sale’ work fine though thanks to the good advice received from Jakob and Springworks

Have a look and see if you can narrow down where you are struggling . I can’t give you access to the code on the site itself but will happily post relevant extracts with explanatory notes.

Looks great! I sent a test message to see what will happen after submition.

so I see – txp:article_custom shows the list of cars, and where do you put this –

<txp:variable name="salesitem" value='<txp:title />'

Offline

Board footer

Powered by FluxBB