So, imagine you have a Joomla site containing lots of pages about…well, anything really. It’d be nice if you could have a ‘request info’ link on each page so users could send you an email with a pre-generated subject line about that page, so you can parse emails (either manually or using some kind of automatic system) coming from the site.
eg: your site has seperate pages about ‘product A’ and ‘product B’. you want a link on ‘product A’s’ page that sends you an email with the subject line ‘yoursite.com: product A enquiry’ and the same for product B.
I can’t find any way of doing this ‘properly’ in Joomla, so here’s a hack I came up with. What it does basically is take a variable from your URL and put it into the subject box. So you can setup a link to ‘http://yoursite.com/contact-us?subject=test subject’ and the contact email form will automagically have the subject line filled in with ‘test subject’.
First up, setup a contact to send the emails from (you’ve probably done this anyway if you have a ‘contact us’ page).
Now publish that contact using the ‘contact’ view under something like yoursite.com/contact-us
now here’s the hack:
open up “components/com_contact/views/contact/tmpl/default_form.php”
the line you’re looking for is this one (it’s line 50 in my copy of the file)
change that to this:
The additional line uses the JRequest class to get the value of our ‘subject’ variable. Then we simply write that into the subject field. We also set a default value ‘website enquiry’ so if the subject variable is unset we have a nice default subject line instead of a blank box. using JRequest::getWord to retrieve the variable means our input is automatically filtered to strip out any html / javascript injection attempts.
you can now set up links anywhere in your site to ‘contact-us?subject=your subject’ to automatically fill out the subject line.