问题
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>
回答1:
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}
来源:https://stackoverflow.com/questions/24920931/how-to-pass-a-parameter-value-from-a-hyperlink-on-one-page-to-another-page-in-ex