Forums

Link to a form: place article title in form field

webcase 02 Jul, 2010
Hi,

I ran through these forums but didn't find the exact answer to my question.

I want to do the following:
[list]1. Manually put a link on several of my article pages to a ChronoForm (not all of them, so I don't want to implement the link in my template)
2. Have the title from the article the user came from put in a form field[/list]

So, when filling out the inquiry form, the user can see the subject line is the same as the article title he was on.

I really need the custom code to catch the article title and fill the form field. Can anyone help me out?

I hope this makes sense and of course I hope to get an answer🙂.

Kind regards,
Maurice
GreyHead 02 Jul, 2010
Hi Maurice,

If you ae adding the links manually add the article id to the link url then look up the title in the Form HTML.

Bob
webcase 02 Jul, 2010
Thanks Bob,

Let's say I want this slightly more automated, since there seem to be over a hundred product pages (I didn't know before, sorry).

What if I put a module with a generic link on every product page in my site (thus not on all other pages)? Is it possible to hand over the article title to the form automatically?

I do hope so...

Thanks in advance,
Maurice
GreyHead 02 Jul, 2010
Hi Maurice,

In the Form HTML you can check the page url to get the article id
<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
. . .
?>


Bob
webcase 02 Jul, 2010
Thanks again but...
Can you be somewhat more specific on how to implement this?

I already put this code on top of all HTML code.

But how do I get the article title in my textbox?
I assume by: value=""

I don't know how to do this.
GreyHead 03 Jul, 2010
Hi Maurice,

The full code will be something like this
<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
$title = '';
if ( $article_id ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT `title` 
      FROM `#__content`
      WHERE `id` = ".$db->quote($article_id)." ;
  ";
  $db->setQuery($query);
  $title = $db->loadResult();
}
echo $title;
?>

Bob
webcase 15 Jul, 2010
Hi Bob (and others),

Thanks!

I have tried implementing this code but I'm afraid I'm not so good with coding... It didn't work. I probably copied it in the wrong place. 😶

Could anyone please help me with some guidelines on how to implement this?

What I have so far:
1. the form, with a text field called 'Subject'
2. a custom HTML module with a hyperlink to the form
3. this module appears on all product pages

So, I need some help with how the link in the module passes through the Article Title to the Subject field.

Thanks in advance
webcase 02 Sep, 2010
Hi all,

Understanding the rist of getting annoying...😶 But... I really would like to ask you to help me with this!

Pls read this thread and I'm looking forward to your answer.

Maurice
GreyHead 03 Sep, 2010
Hi Maurice,

There's not much to do. Add the code I had before into the Form HTML box but change the last line to put the title into a hidden input:
<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
$title = '';
if ( $article_id ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT `title`
      FROM `#__content`
      WHERE `id` = ".$db->quote($article_id)." ;
  ";
  $db->setQuery($query);
  $title = $db->loadResult();
}
?>
<input type='hidden' name='title' id='title' value='<?php echo $title; ?>' />


Bob
webcase 03 Sep, 2010
Hi Bob,

Thanks for your reply! I really appreciate it.

I pasted your code into the HTMLform field (above the existing form code) and I get an error:

com_chronocontact\admin.chronocontact.php(2736) : eval()'d code on line 6

Maybe you can help me out?
GreyHead 03 Sep, 2010
Hi Maurice,

This line should end with a semi-colon
  $db =& JFactory::getDBO();
I'll fix my original posts.

Bob
webcase 03 Sep, 2010
Thanks again! Problem solved.

I want to put the link to the form in a module.

This is the link to the form:
index.php?option=com_chronocontact&chronoformname=inforequestTEST

Can you tell me how I add the ID to this link, so this will be passed through to the form?
GreyHead 03 Sep, 2010
Hi Maurice,

You could just put this code into a mini=form in the module
<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
$title = '';
if ( $article_id ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT `title`
      FROM `#__content`
      WHERE `id` = ".$db->quote($article_id)." ;
  ";
  $db->setQuery($query);
  $title = $db->loadResult();
}
?>
<div><a href='index.php?option=com_chronocontact&chronoformname=inforequestTEST&title=<?php echo $title; ?>' >Click here</a>


Bob
GreyHead 08 Sep, 2010
Hi Maurice,

When you say it gets lost . . . I can't see where you are trying to capture it? In the hidden input named 'Subject'?

What code are you using for this?

Bob
webcase 09 Sep, 2010
Goodmorning Bob,

Thanks for having a look again!

I'll try to explain what code I used and where.

First of all, I have a module with the following code. This module you find at the bottom of the product page.
<?php
if ( !$mainframe->isSite() ) { return; }
$article_id = JRequest::getInt('id', 0, 'get');
$title = '';
if ( $article_id ) {
    $db =& JFactory::getDBO();
    $query = "
    SELECT `title`
     FROM `#__content`
     WHERE `id` = ".$db->quote($article_id)." ;
    ";
    $db->setQuery($query);
    $title = $db->loadResult();
}
?>
<div><a href='index.php?option=com_chronocontact&chronoformname=inforequestTEST&title=<?php echo $title; ?>' >Click here</a> to send us a request about<?php echo $title; ?>.


This links to the Chronoform inforequestTEST.

This form was built with the help of the wizard (awesome tool!). Later on, I added a piece of code you provided.
Here's all the form code:
<input type='hidden' name='Subject' id='title' value='<?php echo $title; ?>' />
<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Information Request: <?php echo $title; ?></h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 110px;">Company name</label>
    <input class="cf_inputbox required" maxlength="150" size="20" title="" id="text_1" name="company" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 110px;">Name</label>
    <input class="cf_inputbox required" maxlength="150" size="20" title="" id="text_2" name="cust_name" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 110px;">Email adress</label>
    <input class="cf_inputbox required validate-email" maxlength="150" size="20" title="" id="text_7" name="cust_email" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 110px;">Comment</label>
    <textarea class="cf_inputbox" rows="5" id="text_6" title="" cols="30" name="comment"></textarea>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_captcha">
    <label class="cf_label" style="width: 110px;">Verification</label>
    <span>{imageverification}</span> 
    
    </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_5" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>

I would like the Title (product page) to appear in the form so the customer doesn't have to fill that out here. And the Title has to appear in the e-mail that is sent to my client.
GreyHead 10 Sep, 2010
Hi Maurice,

There's nothing in the Form HTML to *get* the value of $title. Please add this at the beginning:
<?php
if ( !$mainframe->isSite() ) { return; }
$title = JRequest::getString('title', '', 'get');
?>


Bob
webcase 10 Sep, 2010
Bob,

Thanks so much!
This piece of code solved the problem!
smartsak 17 Jun, 2011
Hi,

I am using the same form for 50 different articles. I need the form to be sent containing some field which has the article name. i used chronoform module in article. then assign this url "index.php?option=com_content&view=article&id=270&Itemid=39" in 50 diffrent articles.I used following code
<table width="500" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="200" valign="top">Vacature-naam</td>
<td valign="top">
<?php
$database =& JFactory::getDBO();
$query = "SELECT * FROM #__content WHERE id='".JRequest::getVar('id')."'";
$database->setQuery( $query );
$article = $database->loadObject();
echo $article->title;
?>
<input type="hidden" name="vacature" value="<?php echo $article->title; ?>" />
</td>
</tr>
</table>
but this code is not working bcoz it sending module article name.
Some guy here know how can I do this?
Please help me sorting this problem. its very urgent
webcase 17 Jun, 2011
@smartsak,

Please carefully follow the instructions Bob gave in this thread, because it solved the exact same issue I had!

In my case, I also needed the article title to be put in the subject field of the form.
smartsak 23 Jun, 2011
Hi

My form is working fine. But problem is that when i submitting form, in email preloaded value is not showing in front text area. i am attaching screen shot of form & mail. Please see it. Please help me sorting this problem. its very urgent
GreyHead 23 Jun, 2011
Hi smartsak,

It looks as though you have some PHP in the Email Template that is being carried over into the email body. Not sure why this is. Does the missing <?php if ( exist in the template?
What's more the PHP doesn't look as though it belongs in the template at all.

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
smartsak 23 Jun, 2011
Hi Bob,

Please attachment zipped file
GreyHead 23 Jun, 2011
Hi smartsak,

There is some junk at the start of the Email template.
<!--?php if ( !$mainframe--->
<p>isSite() ) { return; } $title = JRequest::getString('title', '', 'get'); if ( !$mainframe->isSite() ) { return; } $alias = JRequest::getString('alias', '', 'get'); ?>      {Subject}' /> {Subject1}' /></p>
Go to the Email Setup tab, and in the Email Properties box set Use template Editor to No. Then go back to the template and clean up the code there.

Bob
smartsak 23 Jun, 2011
hi Bob,

Thanks for quick reply. where I put these code
    <!--?php if ( !$mainframe--->
    <p>isSite() ) { return; } $title = JRequest::getString('title', '', 'get'); if ( !$mainframe->isSite() ) { return; } $alias = JRequest::getString('alias', '', 'get'); ?>      {Subject}' /> {Subject1}' /></p>


After clean up the code from template, now it is not showing in email. But the following heads are blank in mail. how to show form data in front of these text.
Gewählte Prämie:
Prämien Nr:

Thanks
Shahzad
smartsak 23 Jun, 2011
Hi Bob,

Thanks for your quick response. Problem resolved. But I want own css for form design. can u help me in this.

Thanks
Shahzad
GreyHead 23 Jun, 2011
Hi Shazad,

The PHP snippet looks like junk to me so I'm not clear what it is meant to be doing. It should probably go in the OnSubmit Before Email box.

You need to add {input_name} in the template to show the values returned from the form with the name of the input inside the curly brackets.

You can add your own CSS in the Form CSS box.

Bob

PS I notice that some of your input names have dashes in them e.g name="la-plz". This will probably cause problems please replace them with underscores e.g. name="la_plz".

PPS You need to sort out the difference between PHP tags <?php . . .?> and HTML comments <!-- . . . --> you have some very odd hybrid tags in your email template <!--?php echo $title; ?-->. These will not work.
smartsak 28 Jun, 2011
Hi Bob,

I need your help. I have created form. Where user fill information. there are three validation field
1. Name
2. telefon
3. email.
but when user fill Kundennummer(customer id) field, then he doesn't need fill any field of form. I am using inputbox required class of joomla.

I am attaching screenshot of form. please see it.

Please help, its very urgent.

Thanks
Shahzad
GreyHead 28 Jun, 2011
Hi Shazad,

I looks to me as though you have built this form yourself and you are not using ChronoForms?

Bob
smartsak 28 Jun, 2011
Hi Bob

Yup, You are right. Can i take your help.

Its urgent

Thanks
Shahzad
smartsak 29 Jun, 2011
Hi Bob

Select An Item from dropdown, Other Get Automatically Selected in multiple selection box in form.

Please help

Thanks
Shahzad
GreyHead 29 Jun, 2011
Hi Shahzad,

I'm very sorry but these are the ChronoForms forums; as you aren't using ChronoForms you are at the bottom of my list of questions to answer. It's unlikely that I will have the time to help you in the near future.

Bob
smartsak 05 Jul, 2011
Hi Bob

like to add subscription services in chronoform. Here's what I envision: ... would like a confirmation email sent to the user with ... like the ability to send reminder notices to customers. ... customize the subscription form so I can capture specific.

Thanks
Shahzad
GreyHead 05 Jul, 2011
Hi Shahzad,

Yes, you can do that in ChronoForms.

Bob
smartsak 30 Jul, 2011
Hi Bob,

I am using chronoform for product enquiry. I want following things to do.
- The Customer starts an enquirie
- The system sends the enquirie information via mail to the website team
(including a confirmation link that has to be confirmed by website team within 12h )
and a short thank you mail to the customer
- The system saves the enquirie information with a timestamp to the database
- a website team can check via the xyz.php if there are
unconfirmed mails in the system db
- if there are still enquiries which are not confirmed within 12h the system sends a copy to website team with a new link
I have attached the form screenshot.

Please help me, I am struggling with last 2 weeks.

Thanks
Shahzad
GreyHead 31 Jul, 2011
Hi Shahzad,

Which parts have you got working? Exactly what help do you need?

Bob
smartsak 01 Aug, 2011
Hi Bob,

Actually, a form is working like that, when user submit a form one mail goes to website team. But now we want that when user submit a form one mail goes to website team with confirmation link, store form data in db and one thank you mail goes to user. After this, when website team click the confirmation link, its confirmed the mail in DB. If they forgot to click that confirmation link, they can check unconfirmed mail in xyz.php and they will also get email reminder after every 12 hours about unconfirmed link. that's the story. I haven't done anything about this functionality.

Thanks
Shahzad
GreyHead 01 Aug, 2011
Hi Shahzad,

Exactly what help do you need?

Bob
smartsak 01 Aug, 2011
Hi Bob,

Thanks for quick reply as usual.
How I do these thing which I mention in previous posts. I am new in coding. Please help, I am desperate.

Thanks
Shahzad
GreyHead 01 Aug, 2011
Hi Shahzad,

You'll need to find someone to help you who has more experience in coding. We can help here whan you have specific problems with your forms and the ChronoForms extnesions but we can't practically write your code for you.

You have quite a big task here, it is all possible but takes some knowledge and experience to get it to work.

Take it one step at a time and by all means ask here when you have a specific problem.

Bob
faros 21 Oct, 2011
Hi
please can you explain me how you created the module, I'm tring to do the same but I got an error when page loads.

I'm trying to put a link in a product page and clicking on this link user is redircted to a form which have to contain the title of the product from which he come.
I tryed to create a module as explained by you but I got an error when I load the page containing the module:
Fatal error: Call to a member function isSite() on a non-object in C:\xampp\htdocs\studiodelta.it\modules\mod_jumi\tmpl\default.php(18) : eval()'d code on line 2

thanks a lot for your help
Fabrizio
GreyHead 22 Oct, 2011
Hi Fabrizio,

If you are using ChronoForms v4 then you can omit the isSite() line so the code becomes
<?php
$title = JRequest::getString('title', '', 'get');
?>

Bob
This topic is locked and no more replies can be posted.