-3 php joomla components upgrade joomla2.5
请提供步骤将Joomla 1.5组件更新为Joomla 2.5组件.
先感谢您.
在适应1.5到1.6以及此DVLancer博客中有很多东西需要学习:
全局变量$ mainframe和$ option
Joomla 1.5
global $mainframe, $option;
Run Code Online (Sandbox Code Playgroud)
Joomla 2.5换成了
$mainframe =& JFactory::getApplication();
$option = JRequest::getCmd('option');
Run Code Online (Sandbox Code Playgroud)
要么
$option = $this->option //If the code is in a controller class derived from JControllerForm
Run Code Online (Sandbox Code Playgroud)
在模板中获取页面标题*
Joomla 1.5
global $mainframe;
$mainframe = &JFactory::getApplication();
$page_title = $mainframe->getPageTitle();
Run Code Online (Sandbox Code Playgroud)
在Joomla 2.5中替换为
$app =& JFactory::getDocument();
$page_title = $app->getTitle();
Run Code Online (Sandbox Code Playgroud)
模板路径
**Joomla 1.5
"templates/templatename/"
Run Code Online (Sandbox Code Playgroud)
Joomla 2.5
$app= & JFactory::getApplication();
$template = $app->getTemplate();
Run Code Online (Sandbox Code Playgroud)
要么
"templates/".$this->template."/"
Run Code Online (Sandbox Code Playgroud)
如何确定您是否在主页上
Joomla 1.5
if( JRequest::getVar('view') == "frontpage" ) {
// You are on the home page
} else {
// You are not
}
Run Code Online (Sandbox Code Playgroud)
Joomla 2.5
$menu =& JSite::getMenu(); // get the menu
$active = $menu->getActive(); // get the current active menu
if ( $active->home == 1 ) { // check if this is the homepage
// You are on the home page
} else {
// You are not
}
Run Code Online (Sandbox Code Playgroud)
访问错误变量
Joomla 1.5
$code = $this->error->code;
$message = $this->error->message;
Run Code Online (Sandbox Code Playgroud)
在Joomla 2.5中,这些变量现在是私有的,必须通过getter方法访问以避免以下错误:
PHP cannot acess protected property error
$code = $this->error->getCode();
$message = $this->error->getMessage();
Run Code Online (Sandbox Code Playgroud)