Page title as subject

Shows some Tutorials

Page title as subject

Postby orsat on Fri Nov 30, 2007 1:04 am

First of all, great component, donation on its way :)

Is it possible to have the page title from which the form was sent as the e-mail subject?

Thank you in advance
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby GreyHead on Fri Nov 30, 2007 1:18 am

Hi orsat,

You can get the page title from the Joomla $mainframe object. To use it put this code in the 'Onsubmit - before email field
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $mainframe->getPageTitle();
?>
and make sure that the other Subject fields are clear.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3788
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Page title as subject

Postby orsat on Fri Nov 30, 2007 3:22 pm

Thank you for the quick reply, I did what you suggested but I am getting this message:

If you choosed to email results than you must ad: Email Address, Email subject, From Name and From Email

In Form Html I have a very basic form:
Code: Select all
Name: <br>
  <input name="name"><br>
Email:<br>
  <input name="Email"><br>
Comment:<br>
  <textarea cols="40" rows="10" name="comment"></textarea><br>
  <button name="submit">Submit</button><br>
In On Submit code - before sending email: I have what you suggested:
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $mainframe->getPageTitle();
?>
Any idea what I am doing wrong?

Again, thank you for the great support !
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby GreyHead on Fri Nov 30, 2007 3:53 pm

Hi orsat,

Assuming that the other three fields are completed, please just put something - 'XXX' will do - in the Subject field on the General tab. The other code snippet will (I hope) overwrite this before the email is sent.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3788
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Page title as subject

Postby orsat on Fri Nov 30, 2007 7:28 pm

OK, the page title is being send as the email subject, however the email subject displays the global site title, not the article title.

The reason I need this is that I have a site with many excursions, tours and accommodation offers. Ideally what I would like to do is to get the article title as the e-mail subject (that way the mail administrator knowns what department to forward the email to) and also display the article title at the beginning of the form when a visitor clicks on the link for booking the tour.

Example:

Requested tour: Article title

Name...
E-mail...
Comments..

By the way, I installed the plugin and tried to call it within a excursion offer page, but I still only get the global site title as the email subject.

Could you please provide more assistance how to achieve this.

Thanks in advance...

P.S I might have some custom work for you guys, a client needs a special component dealing with XML files, what is the best way to contact you on that matter?
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby admin on Fri Nov 30, 2007 9:02 pm

Hi Orsat,

you can use this query to get you the current content item title :
Code: Select all
<?php
$database->setQuery( "
  SELECT title
    FROM #__content
    WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
?>
put this code at the top of the HTML box and later you can use Bob's hack and just replace the $mainframe->getPageTitle() with $title and thats will do it!

If you ever got some contract work then you can post details at the "paid services forum" here, if you dont like to post the details then post a request and somebody will give a reply about the best method of contact :)

Cheers

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 4034
Joined: Mon Aug 14, 2006 5:29 am

Re:Page title as subject

Postby orsat on Fri Nov 30, 2007 10:33 pm

Great support, please bear with me for the last time on this matter :)

At the moment I have:
Code: Select all
<?php
$database->setQuery( "
  SELECT title
    FROM #__content
    WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();

//put the article title in the email subject
$rows[0]->emailsubject = $title;

//display the article title on the page with the form
echo $title;
?>
The article title displays nicely on the page with the form, however the article title is still not send as email subject. Do I have to place the second part of the code in the "On Submit code - before sending email" field?

Thanks...<br><br>Post edited by: admin, at: 2007/12/01 10:00
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby admin on Sat Dec 01, 2007 3:00 pm

Hi Orsat,

Actually you should put this in the "onsubmit before email" :
Code: Select all
<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();

//put the article title in the email subject
$rows[0]->emailsubject = $title;

?>
Cheers

Max<br><br>Post edited by: GreyHead, at: 2007/12/01 13:30Hi Orsat,

Actually you should put this in the "onsubmit before email" :
Code: Select all
<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();

//put the article title in the email subject
$rows[0]->emailsubject = $title;

?>
Cheers

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 4034
Joined: Mon Aug 14, 2006 5:29 am

Re:Page title as subject

Postby minimalniemand on Thu Dec 06, 2007 6:15 pm

Hi,

just found this thread and its exactly what I need. I just cant get it to work.
The Subject line is empty.
I think I made everything like described here. As orsat, I also managed to get the site title sent, but not the article title

I copied the code directly to my onSubmit - before sending mail - field:
Code: Select all
<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();

//put the article title in the email subject
$rows[0]->emailsubject = $title;

?>
I dont have a subject field on my form. The "subject" on the general tab (chrono config) contains 'XXX'

pls tell me if I can provide you with further information
minimalniemand
Fresh Boarder
 
Posts: 17
Joined: Fri Nov 30, 2007 2:17 pm

Re:Page title as subject

Postby GreyHead on Thu Dec 06, 2007 7:33 pm

Hi minimalniemand,

Please try adding these diagnostics:
Code: Select all
<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();

//put the article title in the email subject
$rows[0]->emailsubject = $title;
if ( $debug ) {
  $rows[0]->redirecturl = "";
  echo "_GET: ";print_r($_GET['id']);echo "<br />";
  echo "_GET: ";print_r($title]);echo "<br />";
  echo "_GET: ";print_r($rows[0]->emailsubject);echo "<br />";
}
?>
Now please turn on debug in the General tab, submit the form and see what shows up.

Thanks

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3788
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Page title as subject

Postby orsat on Fri Dec 14, 2007 1:20 am

Thank you for all the help. I will try your last suggestion and post the diagnostics as soon as I get the time. In the meantime I did get the form to send the article title (I am not a coder so the code can for sure be improved :)

Here is what works for me. I wanted to both display the article title in the form (since it is a tour booking form I wanted the customer to see the name of the tour he is booking), and send it as the E-mail subject:

Form HTML:
Code: Select all
<input name="subject" type="text" size="40" value="<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
        $title = $database->loadResult();
echo $title;
?>">

Name: <br>
  <input name="name"><br>
Email:<br>
  <input name="Email"><br>
Comment:<br>
  <textarea cols="40" rows="10" name="comment"></textarea><br>
  <button name="submit">Submit</button>
On Submit code - before sending email:
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $title;
?>
On Submit code - after sending email:
Code: Select all
<?php
echo "Thank you for contacting ... !";
?>


I also would love to see a calendar implementation for date selection.
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby GreyHead on Fri Dec 14, 2007 1:37 am

Hi orsat,

That looks good to me, I'd just clean the first piece of php in the html code a little:
Code: Select all
<?php
$sql =
    SELECT title
        FROM #__content
        WHERE id='".$_GET['id']."'";
$database->setQuery( $sql );
$title = $database->loadResult();
?>
<input name="subject" type="text" size="40" value="<?php echo $title; ?>" />
. . .
I prefer to separate finding the variable values and displaying them as much as I can, but it is a question of taste.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3788
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Page title as subject

Postby orsat on Wed Dec 26, 2007 11:14 pm

Just purchased 2 licenses, I just need one so consider the second license to be the donation I promised :)

The code for displaying and sending the article title works just fine when the form is published within the article (via the plugin).

Now to the new challenge :))

What I really need is to have only a link somewhere within the article pointing to the reservation form, the form should open in a new window and the article title should be displayed as the first line in the form and, when submitted, the article title should be the e-mail title.

The code above doesn´t work if I call the form from a link.

Any help is GREATLY appreciated.
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Re:Page title as subject

Postby GreyHead on Thu Dec 27, 2007 12:45 am

Hi orsat,

On Max's behalf - thanks for buying the licenses.

Should be straightforward to set up the links you want. You could do it with just a text link using the $_GET array to pass the variables from a link like www.mysite.com?link_from=article_title but I think you'd get more functionality from using a full form. So . . .

Set up a ChronoForms form with a hidden field called link_from with the value set to the article title and a submit button that you customise to suit your article. (You can have this saved to the database if you want to be able to track click-throughs in which case you'd probably want to add a hidden id field.) Build a little custom redirect code for the OnSubmit code box to call the second form and pass the key data over.

Embed this into your article page.

Now create your full form including the code in the form html to pull up the article title. I'd probably save the data into the database and just pass the id to allow it to be read into the second form.

Is this sketch enough or does the form code need to be spelt out in more detail?

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3788
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Page title as subject

Postby orsat on Thu Dec 27, 2007 5:14 pm

Is this sketch enough or does the form code need to be spelt out in more detail?


The more detail, the better :) my coding skills are really bad


This is what I had in mind (did this on old joomla and worked like a charm):

I customized the part of code that displayed the PDF icon replacing it with the "reservation" link. Now I could just enable or disable the PDF icon for any page and the "reservation" link would show where needed.

I will give it a try at what you suggested, in the meantime, if you find the time I would really appreciate if you could give me some coding example that I can build on...


Thanks a lot
orsat
Fresh Boarder
 
Posts: 8
Joined: Thu Nov 29, 2007 6:00 pm

Next

Return to ChronoForms How To

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests