您的位置:首页 > 编程语言 > PHP开发

phpwind 房产 数据来源 添加字段调用

2012-06-09 08:52 239 查看
phpwind 房产 数据来源 添加字段调用

系统自带的数据来源的调用字段无法满足我们实际网站需要调用的字段个数(前提是数据库有该字段)。

网上找了半天也没发现有人能解决该问题。官方也没出来个说法。所以得自己研究了。特提供出来大家一起学习。

例如



自带的新房数据来源所能所有字段如下

hid#4

url#index.php?m=house&q=info&hid=4

title#椒江荣安华府

name#椒江荣安华府

hits#84

aveprice#待定

value#0

area#椒江区

image#attachment/

opendate#6月下旬

state#新盘

test3/待定

但是缺少房产的详细地址字段值adress。需求是增加房产详细字段adress调用

步骤。

找到该数据来源文件 

 \mode\house\lib\areasource.class.php 

比如我们要的是新房排序数据。所以定位61行。


到此我们可以发现该类的数据由$houseSortElementService->newHouse($area, $num,'area');  获得,

继续定位\mode\house\lib\housesortelement.class.php 文件

发现12行

function newHouse($round='',$num=0,$type='area',$hid=0) {
return $this->getHouses($round,'opendate',$num,$type,$hid);
}

51行

function getHouses($round,$order,$num,$type='area',$hid=0) {
$num = (int) $num;
!$num && $num = 10;
$_sql_where = $this->getWhereSql($round,$type,'',$hid);
$_sql_order = $this->getOrderSql($order);
$temp = array();
$query = $this->_db->query("SELECT hid,name,logo,area,plate,status,aveprice,developer,opendate,isdimopendate,status,hits,groupbuynum,postnum,collectnum,score FROM pw_house_info $_sql_where $_sql_order ".S::sqlLimit(0,$num));
while ($rt = $this->_db->fetch_array($query)) {
$temp[] = $this->_dataInit($rt);
}
return $temp;
}


由此我们定位到了要修改的地方。在此查询中并没有address 字段

function getHouses($round,$order,$num,$type='area',$hid=0) {
$num = (int) $num;
!$num && $num = 10;
$_sql_where = $this->getWhereSql($round,$type,'',$hid);
$_sql_order = $this->getOrderSql($order);
$temp = array();
$query = $this->_db->query("SELECT * FROM pw_house_info $_sql_where $_sql_order ".S::sqlLimit(0,$num));
while ($rt = $this->_db->fetch_array($query)) {
$temp[] = $this->_dataInit($rt);
}
return $temp;
}


既查询所有。你也可以将所需要的某个值添加进去。

到此前台数据源还调用不出address。还需要改一个地方。这个地方我找了另外个半天。就于自己技术有限。还需要漫长的路要走啊。感叹一下!!!

该位置在124行

function _dataInit($array) {
global $houseBaseUrl;
$data = array();
$data['hid'] 	= $array['hid'];
$data['url'] 	= 'index.php?m=house&q=info&hid='.$array['hid'];
$data['title'] 	= $array['name'];
$data['name'] 	= $array['name'];
$data['hits'] 	= $array['hits'];
$data['address'] 	= $array['address'];
$data['aveprice'] 	= $array['aveprice'];
$data['value'] 	= $array['aveprice'];
$data['area'] 	= $this->_getArea($array['area']);
$data['image']	= $this->_getImageUrl($array['logo']);
$array['opendate'] && $data['opendate'] = !$array['isdimopendate'] ? get_date($array['opendate'],'Y-n-j') : $this->_getDimDate($array['opendate']);
$data['state'] = $this->_getStatus($array['status']);
return $data;
}
 此方法猜测就是对数据库拿出来的数据再处理存进data数组中。  我已经加入了
$data['address'] 	= $array['address'];
address字段的处理。

终于完成。现在天台数据重新调用此就有显示了。

其他数据来源模型猜测也是类似。只要找到该数据来源的sortelement类
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息