On my site, I have users submit an RSForm before having access to a number of articles.
Each article describes a different investment.
I would like to have a button at the head of each article. If the user clicks the button, I'd like to have an email sent to the admin. The email would be written much like the admin emails in RSForm. That is, it would contain the user's name, email, and the particular investment.
A month or so ago a programmer solved a similar problem by hard-coding this into the controller.php file within the banners component. (A user clicks on a banner, and this causes an email to be sent to admin). I'm posting it in the event it might help:
(The purpose of a simple submit button rather than another form is to avoid having to ask the visitor to re-enter their information).
<?php
/**
* @version $Id: controller.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage Banners
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport( 'joomla.application.component.controller' );
/**
* Banners Controller
*
* @package Joomla
* @subpackage Banners
* @since 1.5
*/
class BannersController extends JController
{
function click()
{
$bid = JRequest::getInt( 'bid', 0 );
if ($bid)
{
$model = &$this->getModel( 'Banner' );
$model->click( $bid );
$this->setRedirect( $model->getUrl( $bid ) );
}
}
// ivan: control of custom banners
function do_custom_click()
{
global $mainframe;
$target_link = JRequest::getVar('target_link',null);
if($target_link)
{
// send email
$user =& JFactory::getUser();
if($user->id)
{
$mailfrom="noreply@ascentfx.com";
$fromname="Ascentfx";
$mailTo="admin@mywebsite.com"; "admin@anothersite.com";
$msgSubAdmin="US Referral";
$now = JFactory::getDate();
$date_on = JHTML::_('date', $now->toMySQL(), '%A, %d %B %Y %H:%M');
$msgAdmin="Hi,\n\nUser has clicked on Ascent.Aurapoint banner.\nDate: {$date_on}\nName: {$user->name}\nEmail: {$user->email}\n\nRegards,\nAscentfx";
JUtility::sendMail($mailfrom, $fromname, $mailTo, $msgSubAdmin, $msgAdmin);
}
$mainframe->redirect($target_link);
}
else
$mainframe->redirect("index.php");
}
}
The code for the banner was simply:
<form style="text-align: center;" method="post" action="index.php" mce_style="TEXT-ALIGN: center"><input name="target_link"
value="http://www.a-website.com/" type="hidden">
<input name="task" value="do_custom_click" type="hidden"> <input name="option"
value="com_banners" type="hidden"> <input border="0" name="submit" alt="Ads"
src="http://www.mywebsite.com/images/stories/banner.png"
type="image" mce_src="images/stories/banner.png"></form>
If anyone can help, I'll appreciate it greatly! (PS I do have some modules such as "jumi" which will allow me to put php code within an article).