-3

请提供将 Joomla 1.5 组件更新为 Joomla 2.5 组件的步骤。

先感谢您。

4

1 回答 1

5

在Adapting from 1.5 to 1.6以及从这个 DVLacer 博客中可以学到很多东西:

全局变量 $mainframe 和 $option

Joomla 1.5

global $mainframe, $option;

Joomla 2.5替换为

$mainframe =& JFactory::getApplication();
$option = JRequest::getCmd('option');

或者

$option = $this->option //If the code is in a controller class derived from JControllerForm

获取模板中的页面标题*

Joomla 1.5

global $mainframe;
$mainframe = &JFactory::getApplication();
$page_title = $mainframe->getPageTitle();

在 Joomla 2.5 中替换为

$app =& JFactory::getDocument();
$page_title = $app->getTitle();

模板路径

**Joomla 1.5

"templates/templatename/"

Joomla 2.5

$app= & JFactory::getApplication();
$template = $app->getTemplate();

或者

"templates/".$this->template."/"

如何确定您是否在主页上

Joomla 1.5

if( JRequest::getVar('view') == "frontpage" ) {
  // You are on the home page
} else {
  // You are not 
}

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
}

访问错误变量

Joomla 1.5

$code = $this->error->code;
$message = $this->error->message;

Joomla 2.5中,这些变量现在是私有的,必须通过 getter 方法访问以避免以下错误: PHP cannot acess protected property error

$code = $this->error->getCode();
$message = $this->error->getMessage();
于 2012-07-16T13:53:59.560 回答