<p>The easiest way to solve this, would be to use a <a href="http://buildwithcraft.com/classreference/services/TemplatesService#hook-detail" rel="nofollow">template hook</a> instead, and put all your PHP code in there. </p>

CC BY-SA 3.0
2014-09-09T16:10:57.433Z
2014-09-09T16:10:57.433Z
Victor
<p>We are attempting to implement a number of Pardot forms within Craft templates.  Since Pardot's form actions do not allow us to dynamically specify a return URL, our best choice is to use the form's URL as the return URL.  </p>

<p>Our page is /about/contact.  We want one of three things to happen on this page: </p>

<ul>
<li>If the user has an identifying cookie on their machine, display only a comment field, for example</li>
<li>If the user does not have a cookie saved, display the complete form</li>
<li>If the user is returning from Pardot, set a cookie and display a thank you message.</li>
</ul>

<p>It's important to us that we maintain pretty URLs, so we have created a route in routes.php:</p>

<pre><code>return array(
  'about/contact' =&gt; array('action' =&gt; 'pardotForm/ManageForm'),
);
</code></pre>

<p>Our contact page is an entry in our Landing Page structure.  We've set that entry's slug to be something random so that Craft does not route to the default controller for that entry.  It is set to "contact-us-page".  </p>

<p>We would like to maintain the actual slug on the contact page as "contact" so that we can use slug features in normal ways.  </p>

<p>Is there any possible way to maintain our slug as "contact", our url as "about/contact", and still route to our 'pardotForm/ManageForm' action?</p>

<controller><slug><routing>
Insert action in front of template, while maintaining entry slug
# Insert action in front of template, while maintaining entry slug

(Asked by: username_0 on 2014-08-12)

We are attempting to implement a number of Pardot forms within Craft templates.  Since Pardot's form actions do not allow us to dynamically specify a return URL, our best choice is to use the form's URL as the return URL.  
Our page is /about/contact.  We want one of three things to happen on this page: 

If the user has an identifying cookie on their machine, display only a comment field, for example
If the user does not have a cookie saved, display the complete form
If the user is returning from Pardot, set a cookie and display a thank you message.

It's important to us that we maintain pretty URLs, so we have created a route in routes.php:
return array(
  'about/contact' => array('action' => 'pardotForm/ManageForm'),
);

Our contact page is an entry in our Landing Page structure.  We've set that entry's slug to be something random so that Craft does not route to the default controller for that entry.  It is set to "contact-us-page".  
We would like to maintain the actual slug on the contact page as "contact" so that we can use slug features in normal ways.  
Is there any possible way to maintain our slug as "contact", our url as "about/contact", and still route to our 'pardotForm/ManageForm' action?

**Tags:** controller, slug, routing


---

## 1 answers

### Answer by username_1 on 2014-09-09. Score: 2

The easiest way to solve this, would be to use a [template hook](http://buildwithcraft.com/classreference/services/TemplatesService#hook-detail) instead, and put all your PHP code in there.


---

