Beispiel #1
0
<?php

/*************
 * Retrieve properties hierarchy
 *******************************/
global $wp_query;
$locations = get_term_by('slug', 'locations', 'category');
$metro_manila = get_term_by('slug', 'metro-manila', 'category');
$luzon = get_term_by('slug', 'luzon', 'category');
$visayas = get_term_by('slug', 'visayas', 'category');
$mindanao = get_term_by('slug', 'mindanao', 'category');
function getPropertyList($location)
{
    global $wp_query;
    $args = array('tax_query' => array(array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $location->term_id)), 'post_type' => 'post', 'fields' => 'ids');
    $wp_query = new WP_Query($args);
    $lists = array();
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            $lists[get_the_ID()] = array('name' => get_the_title(), 'link' => get_permalink());
        }
    }
    return $lists;
}
$listing = array('Metro Manila' => getPropertyList($metro_manila), 'Luzon' => getPropertyList($luzon), 'Visayas' => getPropertyList($visayas), 'Mindanao' => getPropertyList($mindanao));
echo json_encode($listing);
Beispiel #2
0
 function getListProperties($returnField, $page, $limit, $language, $site)
 {
     $result = array();
     $context = 'com_jea.projects';
     $mainframe =& JFactory::getApplication();
     $type_id = $mainframe->getUserStateFromRequest($context . 'type_id', 'type_id', 0, 'int');
     $town_id = $mainframe->getUserStateFromRequest($context . 'town_id', 'town_id', 0, 'int');
     $area_id = $mainframe->getUserStateFromRequest($context . 'area_id', 'area_id', 0, 'int');
     $search = $mainframe->getUserStateFromRequest($context . 'search', 'search', '', 'string');
     //    	$order         = $this->_db->getEscaped( JRequest::getCmd('filter_order', 'id'));
     //		$order_dir     = $this->_db->getEscaped( JRequest::getCmd('filter_order_Dir', 'desc'));
     $published = $mainframe->getUserStateFromRequest($context . 'published', 'published', -1, 'int');
     $emphasis = $mainframe->getUserStateFromRequest($context . 'emphasis', 'emphasis', -1, 'int');
     //    	print_r($project_group_id);
     //    	exit;
     //    	$order         = $this->_db->getEscaped( JRequest::getCmd('filter_order', 'id'));
     //		$order_dir     = $this->_db->getEscaped( JRequest::getCmd('filter_order_Dir', 'desc'));
     $offsetLimitArr = U_ReUtils::getOffsetLimit($page, $limit);
     //		if ( $emphasis )
     //		{
     //			echo "typeid khac ko";
     //			echo $published;
     //exit;
     //		}
     //		 $rows = $this->_getList( $sql , $limitstart, $limit );
     //        if ( !$this->_db->getErrorNum() )
     //        {
     //        }
     //		print_r($type_id);
     $cat = JFactory::getURI()->getVar("cat");
     switch ($cat) {
         case 'selling':
             $Kindwhere = " kind_id=1";
             break;
         case 'renting':
             $Kindwhere = " kind_id=2";
             break;
         case 'needbuying':
             $Kindwhere = " kind_id=3";
             break;
         case 'needrenting':
             $Kindwhere = " kind_id=4";
             break;
         default:
             $Kindwhere = " kind_id=1";
             break;
     }
     $conditionParams = $Kindwhere;
     //gan tam
     $conditionParams = ' id<>0';
     //gan tam
     if ($emphasis != -1) {
         $conditionParams .= ' AND emphasis = ' . $emphasis;
     }
     if ($published != -1) {
         $conditionParams .= ' AND published = ' . $published;
     }
     if ($town_id != 0) {
         $conditionParams .= ' AND town_id = ' . $town_id;
     }
     if ($area_id != 0 && $town_id != 0) {
         $conditionParams .= ' AND area_id = ' . $area_id;
     }
     if ($type_id != 0) {
         $conditionParams .= ' AND type_id = ' . $type_id;
     }
     if ($search != NULL) {
         $conditionParams .= ' AND title LIKE "' . $search . '"';
     }
     //		print_r($conditionParams);
     $result['search'] = $search;
     $result['town_id'] = $town_id;
     $result['area_id'] = $area_id;
     $result['published'] = $published;
     $result['emphasis'] = $emphasis;
     $result['type_id'] = $type_id;
     $result['rows'] = getPropertyList($site, $returnField, $conditionParams, $offsetLimitArr, $limit, $language);
     //		print_r($result['rows']);
     //		exit;
     return $result;
     /*
         		$db =& JFactory::getDBO();
     //    		id, name, published, short_description, type_id, address, town_value, area_id, emphasis, checked_out
     //	        $query  = "SELECT '".$returnField."'  FROM jos_jea_project_vi";
     	        $query  = "SELECT id, name, published, short_description, type_id, address, town_id, area_id, emphasis FROM jos_jea_project_vi";
     	        $db->setQuery($query);
     	$result = $db->loadRowList();
     	print_r($result);
     	exit;
     */
     //		$t = getProjectList($returnField, $conditionParams ,0, 10, 'vi',$site);
     //    	$t = U_reSimulTest::getProjectList($returnField,'', $offsetLimitArr, $limit);
     //    	print_r($t);
     //    	exit;
 }