Yii execute code after method

In order to execute a specific code after a Yii controller method (action) called you can proceed by using the following method: afterAction

You cannot specify the action or not

here’s an example:

with the same principle you can call the method: beforeAction

do not forget however to return true before end of the method


Yii CSqlDataProvider sort

In order to sort Yii CSqlDataProvider you have to pass CSort() object to it.

In case the CSqlDataProvider is not sorted you should probably check your query passed to the object. Pay attention not to add a semicolon at the end of your query.



Redirect with Timer in PHP

How you can make a redirect with PHP after a specific number of seconds ?

There are three options available:
The first one is to use a meta refresh

or a javascript function:

You can however use the PHP function header with the following sintax:


Google Maps: address geocoding using php

The following code shows how to geocode an address to obtain google maps latitude and longitude values:

et voilà!


Joomla: email validation

The following code shows how to validate an email with Joomla API


Joomla params/forms YES/NO radio button option

Here below the code for a YES/NO radio button option suitable for example for published option in your table records:

YES is the default option in this specific case.


Joomla – get user groups programmatically

The following code illustrates how to access groups an user is subscribed with Joomla ACL. Groups ids are returned in an array

To test the code, do not forget to lougout and login again should you have modified the user group from the back-end



Joomla: get Objects (database, user, application)

Here below the code to programmatically obtain:

Access to Database Object

Access to User Object:

Access to App Object:

Access to Document Object:



Joomla: get UserGroupId by name programmatically

You can obtain Joomla UserGroup id by name with the following code:



Joomla: redirect user to Login programmatically

If you want your component function to be accessed by your user prior to login programmatically you can use the following code:

You can include the function in your helper class


You can call the function in your MVC code with the following instructions: