저는 Joomla를 처음 사용하기 때문에 Joomla 컨트롤러가 모델에 데이터를 전달하고 모델을 컨트롤러와 컨트롤러로 전달하는 방법을 알고 싶습니다. 이것은 어리석은 질문 일지 모르지만, 나는 그 답을 찾기 위해 정말로 노력했다. 나는 stackoverflow 가족으로부터 도움을 얻을 수 있기를 바랍니다.Joomla MVC (Model View Controller)는 어떻게 작동합니까?
답변
도움이되기를 바랍니다. 그런 다음 사용할보기를 설정합니다. 뷰는 모델을 호출하여 필요한 데이터를 가져온 다음이를 tmpl에 전달하여 표시합니다.
구성 요소/com_test/controller.php
class TestController extends JController
{
// default view
function display() {
// gets the variable some_var if it was posted or passed view GET.
$var = JRequest::getVar('some_var');
// sets the view to someview.html.php
$view = & $this->getView('someview', 'html');
// sets the template to someview.php
$viewLayout = JRequest::getVar('tmpl', 'someviewtmpl');
// assigns the right model (someview.php) to the view
if ($model = & $this->getModel('someview')) $view->setModel($model, true);
// tell the view which tmpl to use
$view->setLayout($viewLayout);
// go off to the view and call the displaySomeView() method, also pass in $var variable
$view->displaySomeView($var);
}
}
구성 요소/com_test/뷰/someview/view.html.php
: 아래 이 모두 함께 작동하는 방법의 간단한 설정입니다class EatViewSomeView extends JView
{
function displaySomeView($var) {
// fetch the model assigned to this view by the controller
$model = $this->getModel();
// use the model to get the data we want to use on the frontend tmpl
$data = $model->getSomeInfo($var);
// assign model results to view tmpl
$this->assignRef('data', $data);
// call the parent class constructor in order to display the tmpl
parent::display();
}
}
구성 요소/com_test/모델/someview.php
class EatModelSomeView extends JModel
{
// fetch the info from the database
function getSomeInfo($var) {
// get the database object
$db = $this->getDBO();
// run this query
$db->setQuery("
SELECT
*
FROM #__some_table
WHERE column=$var
");
// return the results as an array of objects which represent each row in the results set from mysql select
return $db->loadObjectList();
}
}
개
구성 요소/com_test/뷰/someview/tmpl/someviewtmpl.php
// loop through the results passed to us in the tmpl
foreach($this->data as $data) {
// each step here is a row and we can access the data in this row for each column by
// using $data->[col_name] where [col_name] is the name of the column you have in your db
echo $data->column_name;
}
Joomla의 MVC를 사용하여 구성 요소 및 모듈을 만드는 방법에 대한 자세한 자습서를 보려면이 사이트를 확인하십시오. 이 컨트롤러는 URL에보기 변수를 수정 해보기를 사용할 필요가 이러한 결정한다을 사용
죽은 링크 ... 아마도 당신이 너무 다운 투표를 게시했을 때 아니 었어. – araisbec
다른 곳에서 링크 할 때마다 링크 요약을 게시하십시오. –
또한 줌라의 MVC를 사용하여 구성 요소 및 모듈을 만드는 방법에 대한 자세한 튜토리얼 공식의 joomla 문서를 참조하십시오. 희망이 도움이 http://docs.joomla.org/Developing_a_Model-View-Controller_Component/1.5/Introduction
- 1. Model-View-Controller는 인공 지능과 동작 트리에서 훌륭하게 재생됩니까?
- 2. mvc : view-controller는 Spring Tiles2에서 PageNotFound를 발생시킵니다.
- 3. ASP.NET MVC View Model Base?
- 4. UIView 및 MVC (Model View Controller) 패턴
- 5. JavaScript의 Model-View-Controller
- 6. WPF의 Model-View-ViewModel
- 7. model-view-controller의 좋은 예
- 8. joomla breadcrumbs는 어떻게 내부적으로 작동합니까?
- 9. MooTools 및 Joomla, 어떻게 작동합니까?
- 10. backbone.js/access view from model
- 11. WinForms Model-View-Presenter (수동보기)
- 12. WPF Model-View-ViewModel 툴킷
- 13. Model View Controller (MVC) : 모델 및 데이터 유형
- 14. MVC ViewData는 어떻게 작동합니까?
- 15. ASP.Net MVC ActionLink는 어떻게 작동합니까?
- 16. 뷰는 어떻게 작동합니까 (MVC)?
- 17. Qt Model/View 아키텍처가 유용하지 않은 상황입니까?
- 18. UIPopoverController의 View Controller는 키보드가 사라진 후에 크기가 조정됩니다.
- 19. Silverlight 및 Model View Controller 패턴 - 멋지게 재생합니까?
- 20. iOS의 Model-view-controller와 관련된 개념적 질문
- 21. ASP.net Model View Presenter는 시간 가치가 있습니까?
- 22. ASP.NET의 ListView 및 Repeater가있는 Model-View-Presenter
- 23. Databind to DataTemplate.IsSelected to View Model
- 24. Model-view-controller를 사용하는 이유는 무엇입니까?
- 25. Model-View-Presenter : UI 유효성 검사
- 26. View Model 클래스의 RichTextBox.ScrollToEnd()를 호출하십시오.
- 27. ViewModels가 Model View Presenter 패턴에 맞습니까?
- 28. Asp.net MVC 인증 어떻게 작동합니까
- 29. MVC 구성 요소가있는 Joomla 문제
- 30. asp.net mvc model - 내 데이터베이스
BTW MVC는 모델보기 컨트롤러의 약자입니다 – Martin