我如何从 joomlas 布局中调用模型方法来收集数据?我尝试在纬度和经度上使用谷歌地图,在搜索时我检索到一个包含指定数据的对象,并从布局中初始化数据以获取所需的 xml,如下所示。我知道这不是最好的解决方法,但我不想两次执行相同的查询。
控制器调用模型
$model = $this->getModel('item');
$view = $this->getView('item', 'html'); // get the view
$view->setLayout('default:items');
$view->assignRef('url_var', $this->input->get('state'));
$view->assignRef('city', $this->input->get('city'));
视图.html
function display($tpl = null)
{
// Assign data to the view
$this->item_list = $this->get(Items, $this->city);
$this->xml_map = $this->get(createMapXML, $this->item_list);
//Here I do not get back the queries Object list.Shows me the passed ID what I want to pass to model as argument
var_dump($this->get(Items, $this->city));
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JLog::add(implode('<br />', $errors), JLog::WARNING, 'jerror');
return false;
}
// Display the view
parent::display($tpl);
}
var mark;
var pointA;
if (GBrowserIsCompatible()) {
var m = jQuery("#map")[0];
if(m) {
var map = new GMap2(m);
var start = new GLatLng(63.13450320833446,16.69921875);
var zoomLevel = 5;
map.setCenter(start, zoomLevel);
map.addControl(new GSmallMapControl());
//here I would create the xml calling model function
jQuery.get('<?php //$model->createMapXML($this->items)?>',function(data) {
jQuery(data).find('marker').each(function(){
var lat = jQuery(this).attr('lat');
var lng = jQuery(this).attr('lng');
var html = jQuery(this).attr('name')+" ";
html += jQuery(this).attr('msg')+" ";
html += jQuery(this).attr('link');
var point = new GLatLng(lat,lng);
var marker = new GMarker(point);
map.addOverlay(marker);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
});
});
GEvent.addListener(map, 'click', function(overlay, point){
if(mark) {
map.removeOverlay(mark);
}
if(point) {
pointA = new GPoint(point.x, point.y);
mark = new GMarker(pointA);
map.addOverlay(mark);
map.getCenter(point);
var lat = point.y;
var lng = point.x;
map.openInfoWindowHtml(point,form);
}
});
}
}