EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts
ExpressionEngine mini-howtos created by the EE Insider community.
Don’t forget the power of passing Variables through the URL & URL Segments
I recently had a clients site where I needed to pass information from one page to the next. I was passing a custom field to a hidden field of a contact form. I originally started to handle this by creating a cookie and then on the contact page reading the cookie and inputing the information in the needed area. That was until someone in the forms suggested segment variables.
So here is the code to pass the variable to the url:
{exp:weblog:entries weblog="my_weblog" disable="comments|trackbacks|member_data" limit="25"}
<h2>{title}</h2>
<p>{short_blirb}</p>
<a href="/template_group/template_name/{url_title}">Read More</a>
or
<a href="{path=template_group/template_name}{url_title}">Contact Us</a>
{/exp:weblog:entries}
We used the path variable to call the template that we want but we also added in this case the url_title to the end of the url. Now on your next template you can use the data in an array of ways. Here is one way
{if segment_3 != ""}
{exp:weblog:entries weblog="my_weblog" url_title="{segment_3}" limit="1"}
Now you can use what ever fields are associated with that weblog
{/if}
Pass different variables to achieve what ever results you might need.
Email
Print
Post to Twitter
Post to Delicious
Jim Wyse — 16:19 on 08.25.2009
Excellent point! I have used this method to trigger a myriad of events. Thank you messages, error messages. The possibilities are endless.
Thanks,
Jim
Add Your Comment?
You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.
Sign up now (or login).