Hi all, this is my first post here, so be gentle! I need to replace the standard Joomla email button on articles with a button which brings up a form (ideally in a pop-up window) prefilled with the Article title as the e-mail subject and allows them to add their contact details before sending. Creating the form is fine, but how do you:-
a. link it to the article button
b. prefill the article title in the subject
Any help appreciated
a. link it to the article button
b. prefill the article title in the subject
Any help appreciated
Hi DrMopp,
Welcome !
I've no real idea how to do that, the form is simple enough but the Email icon is quite deeply embedded in the com_content code and I suspect that it isn't too easy to catch and divert.
I think I'd start with a good search around the Joomla Extensions forum to see if soemone hadn't already found a workaround.
If, not, then possibly the easiest answer is to turn off the Joomla email icon and create a new one that does exactly what you want.
Bob
Welcome !
I've no real idea how to do that, the form is simple enough but the Email icon is quite deeply embedded in the com_content code and I suspect that it isn't too easy to catch and divert.
I think I'd start with a good search around the Joomla Extensions forum to see if soemone hadn't already found a workaround.
If, not, then possibly the easiest answer is to turn off the Joomla email icon and create a new one that does exactly what you want.
Bob
OK thanks for that, took your advice and ditched the Joomla e-mail icon in favour of an enquire link firing off the form.
But how do I prefill the form subject from the article title?
This code:
Taken from another thread on this forum - returns blank.
But how do I prefill the form subject from the article title?
This code:
<input name="subject" type="text" size="40" value="<?php
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
echo $title;
?>">
Taken from another thread on this forum - returns blank.
at the start of the PHP add this:
Cheers
Max
$database =& JFactory::getDBO();
Cheers
Max
$title is still blank - form html posted below (sorry but site only on localhost at present) -
anyone tell me what I'm doing wrong?
anyone tell me what I'm doing wrong?
<fieldset>
<legend>
<?php
$database =& JFactory::getDBO();
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
echo $title;
?>
</legend>
<div class="form_item">
<div class="form_element cf_text">
<id="" class="cf_text"><h5>I'm interested in this offer, please contact me. My contact details are:-</h5></div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label">Title</label>
<select class="cf_inputbox" id="select_12" size="1" cols="5" name="select_12">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">First Name</label>
<input class="cf_inputbox required" maxlength="150" size="30" id="text_6" name="text_6" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Last Name</label>
<input class="cf_inputbox" maxlength="150" size="30" id="text_7" name="text_7" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Address</label>
<input class="cf_inputbox required" maxlength="150" size="30" id="text_5" name="text_5" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Town/City</label>
<input class="cf_inputbox" maxlength="150" size="30" id="text_9" name="text_9" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">County</label>
<input class="cf_inputbox" maxlength="150" size="30" id="text_10" name="text_10" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Post Code</label>
<input class="cf_inputbox required" maxlength="10" size="8" id="text_18" name="text_18" type="text">
</div>
<div class="clear"> </div></div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Contact Phone No.</label>
<input class="cf_inputbox required" maxlength="20" size="12" id="text_8" name="text_8" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Email Address</label>
<input class="cf_inputbox validate-email" maxlength="150" size="30" id="text_19" name="text_19" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_captcha">
<label class="cf_label">Please type the characters you see in the image opposite</label>
<span>{imageverification}</span>
</div>
<div class="clear"> </div>
</div>
<div class="clear"> </div>
</div>
<div class-"form item">
<div class="form element cf_heading">
<id="" class="cf_text">By submitting this enquiry you consent to our using your contact details in connection with our products. We respect your privacy and will not pass on your details to third parties</div>
</div>
</fieldset>
Realise putting the title as the form legend will be no good when the next stage is to have the article title in the email.
- needs to be a field, but in principle the same problem.
- needs to be a field, but in principle the same problem.
Hi DrMopp,
Silly question but do you have &id=99 (or some other number) in the URL that is calling this form? If not, the query will correctly return a blank result.
If you are testing without using a link to call the form you might need to add a line to set the $_GET variable.
Bob
Silly question but do you have &id=99 (or some other number) in the URL that is calling this form? If not, the query will correctly return a blank result.
If you are testing without using a link to call the form you might need to add a line to set the $_GET variable.
Bob
:oops: Silly question? I think not - (which may be the problem!) - that was it - just have to figure getting into the e-mail subject now.... Thanks for all your help with this.
Hi DrMopp,
For testing add
Bob
For testing add
<?php
JRequest::setVar('id', '99', 'get');
?>
at the start of your form html - but replace 99 with a valid article id.Bob
Back again, I'm afraid. Does this method only apply to articles or can it be used for modules as well?
Hi DrMopp,
Not sure I understand the question - modules don't have ids in the same way but you could add an identifiable link into a module and have it picked up in the form??
Bob
Not sure I understand the question - modules don't have ids in the same way but you could add an identifiable link into a module and have it picked up in the form??
Bob
In the module manager, modules show an ID and a title, using the same link I used in the articles
(but changing the ID!!) the title doesn't come through into the form. Should it?
<a href="index.php?option=com_chronocontact&chronoformname=Enquiry&id=60">
(but changing the ID!!) the title doesn't come through into the form. Should it?
Hi DrMopp,
Ah, I understand. As you are set up at present it will look for the Article with the same id.
Either add a new parameter to tell ChronoForms that this is a module id e.g. &id=60&source=module (with the corresponding code to look it up)
Or, perhaps better, look up the title in the module and add that to the end of the url as a parameter
Bob
Ah, I understand. As you are set up at present it will look for the Article with the same id.
Either add a new parameter to tell ChronoForms that this is a module id e.g. &id=60&source=module (with the corresponding code to look it up)
Or, perhaps better, look up the title in the module and add that to the end of the url as a parameter
Bob
Hi, still can't get module title into form. This is the hyperlink in the module:
also tried source=module rather than source=mod-custom. Any ideas anyone?
<a href="index.php?option=com_chronocontact&chronoformname=Enquiry&source=mod_custom&id=60&title=Offer4567">
also tried source=module rather than source=mod-custom. Any ideas anyone?
Hi DrMopp,
You'll need to add code to unpack the url and add it to the title variable.
Bob
You'll need to add code to unpack the url and add it to the title variable.
Bob
Sorry, don't understand, 'unpack the url''?
Thanks for all your help. Perhaps I'm naive but it can't be an uncommon requirement that where a user submits a form to enquire about a topic (whether that's an article or module) for the email and database entry generated to contain the subject of the enquiry - so far all I've managed to do is get the title of an article displayed on the form! OK that's probably more a reflection of my coding skills than anything else but has anyone out there done this?
Thanks for all your help. Perhaps I'm naive but it can't be an uncommon requirement that where a user submits a form to enquire about a topic (whether that's an article or module) for the email and database entry generated to contain the subject of the enquiry - so far all I've managed to do is get the title of an article displayed on the form! OK that's probably more a reflection of my coding skills than anything else but has anyone out there done this?
Hi DrMopp,
You're the first person I remember who's tried to get the title of a module . . .
For the article title we had some code like this to look up the title . . .
Bob
You're the first person I remember who's tried to get the title of a module . . .
For the article title we had some code like this to look up the title . . .
<?php
$database =& JFactory::getDBO();
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
echo $title;
?>
you probably need something similar for a module.Bob
OK modules look like something to play around with after I've got the basics!
But even for articles, how do I get from 'echo $title' to making the title a field I can both display on the form and pass from the form to an e-mail or database record?
If you can just answer this I'll leave you in peace for a while. :wink:
But even for articles, how do I get from 'echo $title' to making the title a field I can both display on the form and pass from the form to an e-mail or database record?
If you can just answer this I'll leave you in peace for a while. :wink:
Hi DrMopp,
you need to remove echo $title from Bob's code and add it inside a field, something like this:
Cheers
Max
you need to remove echo $title from Bob's code and add it inside a field, something like this:
<input type="hidden" name="articletitle" value="<?php echo $title; ?>" />
Cheers
Max
Thanks for that, worked a treat - that's articles sorted. Now for those pesky modules....
Interesting - I just wanted to open a new thread with nearly the same question.
On my website i have some products, displayed as articles.
On every product page there should be a link to a contact form. I could add that manually, because the articles will not change very often.
In the mail there should be automatically and invisible to the user inserted the header or some description of the product.
Are we talking about the same feature here?
I do not want to change the template mail-button.
On my website i have some products, displayed as articles.
On every product page there should be a link to a contact form. I could add that manually, because the articles will not change very often.
In the mail there should be automatically and invisible to the user inserted the header or some description of the product.
Are we talking about the same feature here?
I do not want to change the template mail-button.
andreasmax,
At last someone else! Yes what you describe is exactly what I needed to do, except that in my case the articles will change often. My original idea was to change either the default email or default article PDF button to fire off a contact form, but now simply have a link in the article - (will be an image but haven't got round to that yet) to the form - the code below in the form gets the article title and puts it in a read-only field. Works a treat - thanks to the guys here - but only on articles, not modules - yet!
At last someone else! Yes what you describe is exactly what I needed to do, except that in my case the articles will change often. My original idea was to change either the default email or default article PDF button to fire off a contact form, but now simply have a link in the article - (will be an image but haven't got round to that yet) to the form - the code below in the form gets the article title and puts it in a read-only field. Works a treat - thanks to the guys here - but only on articles, not modules - yet!
<?php
$database =& JFactory::getDBO();
$database->setQuery( "SELECT title FROM #__content WHERE id='".$_GET['id']."'" );
$title = $database->loadResult();
?>
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo $title; ?>" />
Hi DrMopp,
Modules also have a title field - I just checked. So this code should work OK
Bob
Modules also have a title field - I just checked. So this code should work OK
<?php
$database =& JFactory::getDBO();
$id = JRequest::getInt('id', '', 'get');
$type = JRequest::getString('source', '', 'get');
if ( $type == ''mod_custom' ) {
$table = '#__modules';
} else {
$table = '#__content';
}
$query = "
SELECT title
FROM `$table`
WHERE id = '$id' ";
$database->setQuery( $query );
$title = $database->loadResult();
?>
. . .
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo $title; ?>" />
Bob
Bob,
This code returns:- [list]Parse error: syntax error, unexpected T_STRING in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 44[/list]
Took out what looked like a mismatched quote on line 44 and got:-
[list]Warning: Missing argument 1 for JDatabase::setQuery(), called in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 53 and defined in F:\xampp\htdocs\Joomla15\libraries\joomla\database\database.php on line 543[/list]
Sorry to be a pain but....
This code returns:- [list]Parse error: syntax error, unexpected T_STRING in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 44[/list]
Took out what looked like a mismatched quote on line 44 and got:-
[list]Warning: Missing argument 1 for JDatabase::setQuery(), called in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 53 and defined in F:\xampp\htdocs\Joomla15\libraries\joomla\database\database.php on line 543[/list]
Sorry to be a pain but....
Hi DrMopp,
Sorry, I shouldn't do these things last thing at night.
Bob
Sorry, I shouldn't do these things last thing at night.
$database->setQuery( $query );
Bob
Sorry, only just tested this but it still returns blank or spaces into article title on form, link in referring page is
Form code is now
<a href="index.php?option=com_chronocontact&chronoformname=Enquiry&source=mod_custom&id=60">Enquire</a>
Form code is now
<html>
<head>
<style type="text/css">
legend {
font-size: 14px;
color:#000000;
text-align: center;
}
.cf_label {
display: block;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
}
.cf_text {
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
}
.cf_heading {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
}
.cf_button {
text-align: center;
}
.header {
font-size: large;
}
</style>
</head>
<body>
<fieldset style="border:0;">
<legend>Enquiry Form</legend>
<div class="form_item">
<div class="form_element cf_heading">I'm interested in
<?php
$database =& JFactory::getDBO();
$id = JRequest::getInt('id', '', 'get');
$type = JRequest::getString('source', '', 'get');
if ( $type == 'mod_custom' ) {
$table = '#__modules';
} else {
$table = '#__content';
}
$query = "
SELECT $title
FROM `$table`
WHERE id = '$id' ";
$database->setQuery( $query );
$title = $database->loadResult();
?>
. . .
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo $title; ?>" />
</div>
<div class="clear"> </div>
</div>
<fieldset>
<legend>
Please contact me
</legend><br>
<div class="form_item">
<div class="form_element cf_dropdown"><label class="cf_label">Title</label>
<select class="cf_inputbox" id="select_1" size="1" cols="5" name="title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="cf_label">
<label class="cf_label">Name*</label>
<input class="cf_inputbox required" maxlength="150" size="30" id="field1" name="name" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label">Address</label>
<input class="cf_inputbox" maxlength="150" size="30" id="field2" name="AddressLine1" type="text">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label">Town/City</label>
<input class="cf_inputbox" maxlength="150" size="30" id="field3" name="Town" type="text">
</div>
<div class="clear"> </div>
<div class="form_item"><label class="cf_label">County</label></div>
<div class="form_element cf_textbox">
<input class="cf_inputbox" maxlength="150" size="30" id="text_10" name="County" type="text">
</div>
<div class="clear"> </div>
<div class="form_item"><label class="cf_label">Post Code*</label></div>
<div class="form_element cf_textbox">
<input class="cf_inputbox required" maxlength="10" size="8" id="text_18" name="PostCode" type="text" style="width: 89px"></div>
</div>
<div class="clear"> </div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Contact Phone No.*</label>
<input class="cf_inputbox required" maxlength="20" size="12" id="text_8" name="text_8" type="text" style="width: 124px">
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Email Address*</label>
<input class="cf_inputbox validate-email" maxlength="150" size="30" id="text_19" name="text_19" type="text">
</div>
<div class="clear"> </div>
</div>
<center>
<input type="radio" name="contactby" value="phone" checked="checked">By Telephone
<input type="radio" name="contactby" value="email">By Email
</center>
<br>
</fieldset>
<center>
<div class="form_item">
<div class="form_element cf_captcha">
<label class="cf_label">Please type the characters you see in the image*</label>
<span>{imageverification}</span>
</div>
<div class="clear"> </div>
<div class="form_item">
<div class="form_element cf_button">
<input value="Submit" name="undefined" type="submit">
</div>
</div>
<div class="clear"> </div>
</div>
</center>
<div class="form item">
<div class="form element cf_text">Field marked * are required. We respect your privacy and will not pass on your details to third parties</div>
</div>
</fieldset>
</body>
</html>
still returns blank or spaces into article title on form
I cant understand this !Max
What I should have said is that last code posted i.e with the if statement, doesn't work for articles either - the original code definitely does.
Not debugged - to be honest wouldn't know how to do that - but following warnings show in Firefox Error Console:
Warning: Expected ':' but found 'undefined'. Declaration dropped.
Source File: http://localhost/joomla15/
Line: 0
Warning: Expected ':' but found 'undefined'. Declaration dropped.
Source File: http://localhost/joomla15/index.php/component/chronocontact/?chronoformname=Enquiry&id=48
Line: 0
to debug the code please try this instead of the form code you have and let me know the output:
Cheers
Max
<?php
$database =& JFactory::getDBO();
echo $id = JRequest::getInt('id', '', 'get');
echo $type = JRequest::getString('source', '', 'get');
if ( $type == 'mod_custom' ) {
$table = '#__modules';
} else {
$table = '#__content';
}
echo $query = "
SELECT $title
FROM `$table`
WHERE id = '$id' ";
$database->setQuery( $query );
echo $title = $database->loadResult();
?>
Cheers
Max
Output as below:
Has the right ID, type and table but title still blank.
60mod_custom SELECT FROM `#__modules` WHERE id = '60'
Has the right ID, type and table but title still blank.
SELECT FROM `#__modules` WHERE id = '60'
and
$query = "SELECT $title FROM `$table` WHERE id = '$id' ";
what should the variable $title hold in the last statement ? this is the problem, its simply empty, or should it be "title" without the "$"? your table has a column called "title" ?
Cheers
Max
The title field in the Joomla admin module display has the value 'Offer 4567'.
Both the modules and content tables have 'title' fields, but when looking directly at the DB table in MySQL the title field in the modules table is 'text', but in the content field is VARCHAR(255) could that be the problem?
Both the modules and content tables have 'title' fields, but when looking directly at the DB table in MySQL the title field in the modules table is 'text', but in the content field is VARCHAR(255) could that be the problem?
well no but if so then this line:
Cheers
Max
$query = "SELECT $title FROM `$table` WHERE id = '$id' ";
should be $query = "SELECT title FROM $table WHERE id = '$id' ";
Cheers
Max
OK so this is the (debugging) )code I have now,
It gives this error:-
[list]Parse error: syntax error, unexpected '=', expecting ',' or ';' in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 54[/list]
Thanks for continuing help!
<?php
$database =& JFactory::getDBO();
echo $id = JRequest::getInt('id', '', 'get');
echo $type = JRequest::getString('source', '', 'get');
if ( $type == 'mod_custom' ) {
$table = '#__modules';
} else {
$table = '#__content';
}
echo $query = "
SELECT title
FROM $table
WHERE id = '$id' ";
$database->setQuery( $query );
echo title = $database->loadResult();
?>
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo title; ?>" />
It gives this error:-
[list]Parse error: syntax error, unexpected '=', expecting ',' or ';' in F:\xampp\htdocs\Joomla15\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 54[/list]
Thanks for continuing help!
Hi DrMopp,
The error message suggests an error on line 54 of this code, but there aren't 54 lines :?
(I also can't identify what might be happening on line 320 of chronocontact.html.php in my copy).
However, there are still a couple of bugs in there
Bob
The error message suggests an error on line 54 of this code, but there aren't 54 lines :?
(I also can't identify what might be happening on line 320 of chronocontact.html.php in my copy).
However, there are still a couple of bugs in there
echo title = $database->loadResult();
?>
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo title; ?>" />
needs to be$title = $database->loadResult();
?>
<input class=cf_inputbox name="articletitle" readonly="readonly" value="<?php echo $title; ?>" />
with $ signs in front of the two titles here where they are php variable names (in the $query statement 'title' is a database field name and doesn't need the $).Bob
Sorry, didn't send you the whole code for the form, hence no line 54! 😶
However the good news is - fixed the two errors you pointed out and .... it WORKS! for modules and articles.😀
Thanks for your all your and Max's efforts.
(only hope I can take out the debug code without breaking it!)
However the good news is - fixed the two errors you pointed out and .... it WORKS! for modules and articles.😀
Thanks for your all your and Max's efforts.
(only hope I can take out the debug code without breaking it!)
HI DrMopp,
Just remove 'echo ' from the lines that still have it at the beginning. Leave the rest of the line in each case.
Bob
Just remove 'echo ' from the lines that still have it at the beginning. Leave the rest of the line in each case.
Bob
Hello,
This sounds like the exact solution I am after, but I am afraid after reading the thread it has all pretty much gone over my head - is there any way you could supply a 'enquiry form from articles for dummies' step by step version?
or am I pushing my luck? 🙂
This sounds like the exact solution I am after, but I am afraid after reading the thread it has all pretty much gone over my head - is there any way you could supply a 'enquiry form from articles for dummies' step by step version?
or am I pushing my luck? 🙂
Hi crashtackle,
install and enable the Chronoforms mambot/plugin and use the formula {chronocontact}form_name{/chronocontact} to show the form!
Regards
Max
install and enable the Chronoforms mambot/plugin and use the formula {chronocontact}form_name{/chronocontact} to show the form!
Regards
Max
Hi Max,
Done that - thanks. works great. But how do I implement the code to show which article it came from?
Thanks.
Done that - thanks. works great. But how do I implement the code to show which article it came from?
Thanks.
Hi, there are some posts about this here, you need to query the content table for the id and get the title!
Max
Max
This topic is locked and no more replies can be posted.