Category: "Tips for PHP"
Good captcha plug-in in Joomla
I got a lot of spam from the Joomla contact form, I need a captcha plug-in. Actually, there are a lot of anti-spam plug-in in Joomla. But they are fairly complex, some of them even have a custom-build contact form. That is too much.
After I spent some time to research on the internet, I found a plug-in calls Joo ReCaptcha. That is very simple. After I installed that, the contact form will have ReCaptcha image under the input fields. That is great!
Atahualpa 3.6.7 - Adsense Bug
I got a new website which is using Atahualpa 3.6.7 wordpress template. Yesterday, we tried to place an Adsense code in there. It doesn't work. We believed the website were blocked by Adsense. That is not truth! We tried to switched the template, then that works! The solution is simple to use the latest version of Atahualpa, they already fixed this bug!
JSON View in Joomla
I have tried to call the json view in the controll, like this:
Code:
Code
$view = &$this->getView('view','json','prefix'); | |
$view->display(); |
But that is still with the default html template, even I have used, json_encode.
I have found out I have to put "format=json" in the request url.
How to pass the value from the controller to a view
I am implementing a MVC component. I wish to pass a value from the controller to the view for displaying. This is very easy. You need to assign the value from the controller.
Code
$view = &$this->getView('viewname','fromat','prefix'); | |
$view->assign('ids','1,2,4'); |
Then in the view:
Code
$ids=$this->get('ids'); |
That is easy.
Not Displaying Template in Joomla Component.
Joomla is using the MVC Pattern. There is another feature. You can override display function in controller to trigger whether the controller will display the template. In the following example, I will not display the template when the form is submitted.
Code
function display(){ | |
$task = JRequest::getVar('task'); | |
if( $task != 'enter' ){ | |
parent::display(); | |
} | |
} |