-3

Joomla 1.5 コンポーネントを Joomla 2.5 コンポーネントに更新する手順を教えてください。

前もって感謝します。

4

1 に答える 1

5

1.5から1.6への適応、およびこのDVLancerブログから学ぶべきことがたくさんあります:

グローバル変数$mainframeおよび$option

Joomla 1.5

global $mainframe, $option;

Joomla2.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();

Joomla2.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 に答える