Nona
Nona

Reputation: 5462

How to pass a parameter value from a hyperlink on one page to another page in ExpressionEngine?

I am on an expression engine entry page with a few hyperlinks...

<a href="http://example.com/expressionenginepage/">Go Form</a>
<a href="http://example.com/expressionenginepage/">Go2 Form</a>

Based on which hyperlink I click, I want to navigate to another expression engine page with a contact form and dynamically set the value of the subject field based on which hyperlink was clicked on the previous page......How do I go about doing this? Can I set a parameter value which then gets passed to the expressionengine session so I can reference it in the Contact Form page? Perhaps a mechanism like the below?

<a href="http://example.com/expressionenginepage/" ee_value=1>Go Form</a>
<a href="http://example.com/expressionenginepage/" ee_value=2>Go2 Form</a>

Upvotes: 0

Views: 106

Answers (1)

AllInOne
AllInOne

Reputation: 1450

I've done something similar to this with selects, but the principle is the same for text fields.

Simply treat the 2nd URL segment as the variable.

So you have your form page here:

http://example.com/expressionenginepage/

If you want the subject line on that form to be pre-filled out as "Please call me", compose the link as

http://example.com/expressionenginepage/call

If want the subject line on that form to be pre-filled out as "I need help", compose the link as http://example.com/expressionenginepage/help

Then on your template 'expressionenginepage' look at the segment_2 variable and conditionally serve the subject line that you desire.

{if segment_2 == 'call'}
  <input id="subject" type="text" value="Please call me">
{if:elseif segment_2 == 'help'}
  <input id="subject" type=text value="I need help">
{if:else}
  <input id="subject" type=text value="">
{/if}

Upvotes: 1

Related Questions