Automatic input of document page title into form

Post any questions you may have here

Automatic input of document page title into form

Postby arvendal on Thu Jul 17, 2008 9:18 am

Hi,

I need to know how I in a simple way can get an automatic input of the document title into a Chronoform. Let's say this is the case:
  1. A form called "More info" is created in Chronoform.
  2. The form is added via plugin to let's say 5 different articles
  3. Each article has a specific page title <title>
  4. The page title is automatically added to the form and sent to the recipient, thus showing on which matter more information is requested

Hope you get my point. The aim is to bring down the number of forms to maintain. It would be great to have just one form for several topics/articles.

Thanks
--Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby GreyHead on Fri Jul 18, 2008 12:01 pm

Hi Arvendal,

You can possibly get some page info from the $mainframe object - see this post for a starter - though this didn't seem to give the page title.

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: 3966
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Automatic input of document page title into form

Postby arvendal on Sat Jul 19, 2008 10:31 am

Hi,

I like your fast replies!

Unfortunately my knowledge in PHP scripting is poor and therefor I can't see what to do with your advice.

But I found another Q&A at your forum that seems to address my problem, or at least provide the same result I am looking for. Since sendmail doesn't work on my local wampserver, I need to test this on a real web server. I will do that and get back to you with the result.

Any more advice you have is always welcome!

Yours
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby GreyHead on Sat Jul 19, 2008 12:17 pm

Hi Mats,

Yes, that other thread looks good (I've cleaned up all the code that was messed up by the forum change I hope).

If you have a gmail or hotmail account you may find that you can use their mail servers with a wamp server.

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: 3966
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Automatic input of document page title into form

Postby arvendal on Sat Jul 19, 2008 3:10 pm

Hi,
I tried the trick in the Q&A I mentioned above. But the only thing I got was the site name as subject. Maybe I did something wrong?

This is what I did:

I made a test form and in the Form HTML part of the form code tag i Chronoforms I wrote:
Code: Select all
<?php
$database->setQuery( "
  SELECT title
    FROM #__content
    WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
?>
<input type="text" name="text" />
<input type="submit" name="submit" value="Submit" />
{imageverification}
And then I put this in the "On Submit code - before sending email":
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $title;
?>
This returned an e-mail with the subject of the web site name and the content of the text field.

I hope you can help me out on this. It would solve my problem if the page title could be returned instead. I think it's close now.

Yours
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby arvendal on Sun Jul 20, 2008 8:10 am

Hi

I have continued to investigate the code examples and I think I can make these conclusions:

1. Both the codes:
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $title;
?>
and
Code: Select all
<?php
global $mainframe;
$rows[0]->emailsubject = $mainframe->getPageTitle();
?>
manage to collect the site name as e-mail subject (with or without the code below).

2. The code
Code: Select all
<?php
$database->setQuery( "
  SELECT title
    FROM #__content
    WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
?>
doesn't affect the way the e-mail subject is chosen, i.e. it doesn't seem to collect the page title instead of the site name. Could there be any syntax error in this code?

I used Joomla 1.0.15 for this investigation.

Btw, today I finally purchased the license for Chronoforms. I really like this extension and I have decided to use it on 2-3 different web sites.

Yours sincerely,
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby GreyHead on Sun Jul 20, 2008 11:16 am

Hi Mats,

A little digging got me to this
Code: Select all
<?php
$menu = $mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
$title = $params->get( 'header' );
?>
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: 3966
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Automatic input of document page title into form

Postby arvendal on Sun Jul 20, 2008 11:36 am

Hi,

thanks for all your effort. May I please just ask if you could specify what code to put where, i e what code should go in form code HTML field and On Submit code - before sending email field?

Yours sincerely,
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby arvendal on Sun Jul 20, 2008 11:50 am

Sorry!

I think I have given you some wrong information.
The info that is returned as e-mail subject never seems to be Joomla site name, instead nothing is returned. The subject line is empty.

Sorry if I confuse you!

Yours
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby arvendal on Sun Jul 20, 2008 11:56 am

Forgot one thing:

I wrote xxx as e-mail subject in the created form and that value seems always to be overwritten by all the different PHP codes I have used.

Yours
--Mats
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby GreyHead on Sun Jul 20, 2008 1:20 pm

Hi Mats,

The only place that the page title is available is actually in the page so you need to identify this in the form html and pass it back for processing. Form Html:
Code: Select all
// some form code
<?php
$menu = $mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
$page_title = $params->get( 'header' );
?>
<input type="hidden" name="page_title" value="<?php echo $page_title; ?>" />
and in the OnSubmit Before box
Code: Select all
<?php
$rows[0]->emailsubject = $_POST['page_title'];
?>
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: 3966
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Automatic input of document page title into form

Postby arvendal on Mon Jul 21, 2008 4:33 pm

Hi,

I really hope you will not get tired of me... :)

This last code example really made it came more close to what I was hoping for. Near, but not quite there.

The code generated a message that had the text from "page title" in Joomla's main menu item. Look at this screen shot of the result:

Image

I would like to catch the Title, "Ett ankhuvud" and turn that into a e-mail subject. (Ett ankhuvud is Swedish for "a duck head" - just an text title)

Yours sincerely
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby arvendal on Wed Jul 23, 2008 7:18 am

Hi,

Since I had only tried your code examples on a Joomla 1.0.15 site I began to wonder if there may be a difference if I use the latest Joomla version, therefore I installed Joomla 1.54 on my hosts server and added the codes to a Chronoform I made. But when the page containing the code:

Code: Select all
<!--Form HTML-->
<?php
$menu = $mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
$page_title = $params->get( 'header' );
?>
<input type="hidden" name="page_title"
  value="<?php echo $page_title; ?>" />

<!-- On Submit code - before -->
<?php
$rows[0]->emailsubject = $_POST['page_title'];
?>
was opened in Explorer I only got the 500 server error message. When I cleaned the form from the code above, the page loaded all right.

I hope you may be able to give me some advice on this question. The forms are meant to be used on a travel agency's website, where it would be very convenient to use the same form for all destinations, when the purpose is for the visitor to ask for more information on a specific destination.

If there are more users who need this feature maybe it could be implemented in a future version of this fine and useful extension.

Yours sincerely
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Re:Automatic input of document page title into form

Postby GreyHead on Wed Jul 23, 2008 11:09 am

Hi Mats,

I don't see why you'd get a server error with that code - though you may well be missing a global $mainframe; at the beginning.

There are big differences between Joomla 1.0.x and Joomla 1.5.x in where some data is stored. My code was tested in 1.5 (I think).

The problem we have so far here is not really a ChronoForms problem but finding the *right* data from Joomla to allow you to distinguish between the pages.

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: 3966
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Automatic input of document page title into form

Postby arvendal on Wed Jul 23, 2008 12:44 pm

Thanks for your help.

I have contacted my host to see if there's any problem with the server configuration.

My template has the command
Code: Select all
<?php echo $mainframe->getCfg('sitename');?>
so I can't understand why the $mainframe creates problem when I try to use it in the form.

I will look around for a solution on how to retrieve the value of the Page title. If I find a solution I will let you know.

Thanks for your effort. You are great.

Yours
--Mats Arvendal
arvendal
Fresh Boarder
 
Posts: 18
Joined: Sun Dec 02, 2007 9:07 am

Next

Return to ChronoForms Questions & Answers

Who is online

Users browsing this forum: MSN [Bot], Yahoo [Bot] and 2 guests