我想跟着mvc tutorial並安裝code與擴展管理器。Joomla的主模板
這一切工作正常和丹迪,但我想弄清楚所有頁面的其餘部分來自哪裏。該模板只打印出「Hello World」,但該頁面與菜單和全部一起完成。
有沒有辦法只打印出「Hello World」? following表明我可以編輯某些文件(未指定內容)並將其打印出JSON,但當輸出被某種主頁面模板包圍時,它將是無效的JSON。
安裝插件後,我有以下文件:
/components/com_helloworld/helloworld.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by HelloWorld
$controller = JController::getInstance('HelloWorld');
// Perform the Request task
$controller->execute(JRequest::getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
/components/com_helloworld/controller.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* Hello World Component Controller
*/
class HelloWorldController extends JController
{
}
/組件/com_helloworld/views/helloworld/view.html.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* HTML View class for the HelloWorld Component
*/
class HelloWorldViewHelloWorld extends JView
{
// Overwriting JView display method
function display($tpl = null)
{
// Assign data to the view
$this->msg = 'Hello World';
// Display the view
parent::display($tpl);
}
}
/components/com_helloworld/views/helloworld/tmpl/default.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<h1><?php echo $this->msg; ?></h1>
我可以輸出東西/components/com_helloworld/helloworld.php和離開它,但沿的方式思維更生成輸出和控制器獲取數據的視圖。