Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I have a site which has a clonable template used for 'jobs'.

The site has a contact form used for multiple purposes and I want to link to the contact form from each job, passing the page id as a url parameter to the contact form.

I want the contact form to then determine the title of the job and pre-populate the message field in the form with the title of the job.

I'm thinking I need a <cms:if> to determine if there has been a job id passed in the URL and then use that ID to get the page title for that specific 'job'.

Struggling to make this work. Pointers much appreciated. Thank you!
I have answered this myself. Problem was I forgot to set a variable to be in the global scope. I was doing it right.

But is this the best way to do this?

Code: Select all
<cms:set jid="<cms:gpc 'jid' method='get'/>" />
<cms:set cfmessage="" scope='global' />
<cms:if jid gt '0'>
    <cms:pages masterpage="jobs.php" k_page_id=jid>
        <cms:set cfmessage=k_page_title scope='global' />
    </cms:pages>
</cms:if>
I think just a couple of modifications and the code should be fine -

1. The param to use with <cms:pages> is 'id' (and not 'k_page_id')
2. It should be better to validate the ID a little more robustly.
Code: Select all
<cms:set jid="<cms:gpc 'jid' method='get' />" />
<cms:set cfmessage="" scope='global' />

<cms:if "<cms:validate jid validator='non_zero_integer' />">
    <cms:pages masterpage="jobs.php" id=jid limit='1'>
        <cms:set cfmessage=k_page_title scope='global' />
    </cms:pages>
</cms:if>


As an aside, on the jobs page you may use the following code to add the 'jid' param (will adjust to prettyURL being on or off) -
Code: Select all
<cms:set my_contact_link="<cms:link 'contact.php' />" />
<a href="<cms:add_querystring my_contact_link "jid=<cms:show k_page_id />" />"><cms:show k_page_title /></a>

Hope this helps.
Lovely. Thank you :)
4 posts Page 1 of 1