Reported by Lucky1968 | July 31st, 2011 @ 12:23 AM
Hi,
I'm developing my own CMS and I want to use the Recaptcha plugin to protect sending mails from the site.
My contact form is an element (views/elements/contact_form.ctp) which is using the MailsController to email the form.
The administrator can choose to show the contact form on the site in different pages belonging to different controllers although in most cases the administrator is likely to only show the contact form in the contact page (which is a view of the ContentPagesController). So the contact_form.ctp-element can be included in different views of different controllers but is most likely only used in 1 particular view of 1 controller.
Since I don't want to include the 'Recaptcha.Recaptcha'-component in all controllers which offer the possibility to include the contact form I would prefer to include the 'Recaptcha.Recaptcha'-component only when the contact_form.ctp-element is included in the view.
So is there a way to include the 'Recaptcha.Recaptcha'-component from within the contact_form.ctp-element? Or can the contact_form.ctp-element access the 'Recaptcha.Recaptcha'-component which is included in the MailsController anyway although the element is included in a view of another (f.e. ContentPagesController) controller?
FYI: Including the 'Recaptcha.Recaptcha'-component in the AppController looks like overkill to me since in most cases the component will only be used in 1 particular page (contact page) of 1 particular controller.
Also, trying to add 'Recaptcha.Recaptcha'-component to the AppController like this
class AppController extends Controller {
var $components = array('Auth', 'Session', 'Recaptcha.Recaptcha');
}
results in this error:
Notice (8): Undefined property: PagesController::$Page [CORE/plugins/recaptcha/controllers/components/recaptcha.php, line 86]
Notice (8): Trying to get property of non-object [CORE/plugins/recaptcha/controllers/components/recaptcha.php, line 86]
Fatal error: Call to a member function attach() on a non-object in /Applications/MAMP/htdocs/LuckyCMS/plugins/recaptcha/controllers/components/recaptcha.php on line 86
Thanx for any help.
Luc