Calling different scripts in Joomla

Now we’ve changed a lot of our database and variable-retrieving code, but we still don’t know how to properly call our different script-files our former script consists of.If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:
Case switching for multiple scripts
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
require_once( $mainframe->getPath( 'front_html' ) );
$task = mosGetParam( $_REQUEST, 'task', 'view' );
switch ($task) {
case 'edit':
include('edit.php');
break;
case 'save':
include('save.php');
break;
case 'view':
default:
include('view.php');
break;
}
?>
As you can see, we first read the value of the POST-variable “task” and then differentiate between the different tasks at hand. When we find our correct task, we link to the file with the corresponding code. You could also link to a function, which would reduce the number of files in your components-folder and gives you the chance to easily call, for example, the view-function after saving your data.

Nhận xét

Bài đăng phổ biến từ blog này

Ký tự viết tắt trong chat & email

dung lượng RAM lớn nhất mà HĐH cấu trúc 32-bit nhận được

Ubuntu LAMP Server