Научить видеть другие категории php

manaz
На сайте с 13.12.2013
Offline
61
543

Добры день. Есть модель категорий, она написана только под одну категорию, то б то если имеются в базе еще родительские категории она не видит их.

В базе была ячейка catid я добавил еще ячеек catid1 catid2 catid3 но вытягиваются данные только по одной ячейке

Начал модифицировать модель категорий но все ровно пока на одном месте все...

Помогите разобраться как ее на три учить выводить все три ячейки

Вот сама модель это уже после моих модификаций.



<?php

/*
* @version $Id: category.php 3.5.0 2017-03-10 $
* @package Joomla
* @copyright Copyright (C) 2013-2014 Jom Classifieds
* @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla Libraries
jimport('joomla.application.component.model');

class JomClassifiedsModelCategory extends JModelLegacy {

var $catid;
var $catid1;
var $catid2;
var $catid3;
var $catid4;
var $catid5;
var $catid6;
var $catid7;
var $catid8;
var $catid9;
var $catid10;
var $catid11;
var $catid12;
var $catid13;
var $catid14;
var $catid15;
var $catid16;
var $catid17;
var $catid18;
var $catid19;
var $catid20;
var $catid21;
var $catid22;
var $catid23;
var $catid24;
var $catid25;
var $catid26;
var $catid27;
var $catid28;
var $catid29;
var $catid30;
var $catid31;
var $catid32;
var $catid33;


var $limit;
var $limitstart;
var $filter_order;
var $filter_view;
var $catids;
var $catids3;
var $filter_location;

function __construct() {
$mainframe = JFactory::getApplication();
$params = $mainframe->getParams();
$config = JomclUtils::getCfg();

if($id = JRequest::getInt('id')) {

$this->catid = $id;

if($this->catid3==-1){
$this->catid3 = $id;
}


} else {
$this->catid = $params->get('catid', 0);

$this->catid3 = $params->get('catid3', 0);
}
$this->limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $config->adsperpage, 'int');
$this->limitstart = JRequest::getVar('limitstart', 0, '', 'int');
$this->limitstart = ($this->limit != 0 ? (floor($this->limitstart / $this->limit) * $this->limit) : 0);
$this->filter_order = JomclUtils::getOrderByState($config->deforderby);
$this->filter_view = JomclUtils::getViewState($config->defviewmode);
if(!$this->catid == 0) {
$this->catids = JomclUtils::getChildren('categories', $this->catid, $config->inclsubcats);
} else {
$this->catids = 0;
}


if(!$this->catid3 == -1) {
$this->catids = JomclUtils::getChildren('categories', $this->catid3, $config->inclsubcats);
} else {
$this->catids = 0;
}






$this->filter_location = $mainframe->getUserState("location_state");

parent::__construct();
}

function getChildCategories() {
$db = JFactory::getDBO();
$query = 'SELECT * FROM #__jomcl_categories';
$query .= ' WHERE published=1 ';
$query .= ' AND parent='.$this->catid;

$query .= ' ORDER BY ordering';
$db->setQuery($query);
$items = $db->loadObjectList();



return $items;



}





function getItems() {
$db = JFactory::getDBO();
$query = 'SELECT a.*, c.title as category, c.alias as catalias, ctry.name as ctryname, r.name as regname, ctry.alias as ctryalias, r.alias as regalias, t.name as tagname, t.type as tagtype, t.image as tagimage, t.txtcolor as tagtxtcolor, t.bgcolor as tagbgcolor, t.bdrcolor as tagbdrcolor, t.style as tagstyle, m.name as memname FROM #__jomcl_adverts AS a';
$query .= ' LEFT JOIN #__jomcl_categories AS c ON a.catid = c.id or a.catid3 = c.id';


$query .= ' LEFT JOIN #__jomcl_locations AS ctry ON ctry.id = a.country';
$query .= ' LEFT JOIN #__jomcl_locations AS r ON r.id = a.region';
$query .= ' LEFT JOIN #__jomcl_tags AS t ON a.tagid = t.id';
$query .= ' LEFT JOIN #__jomcl_premium AS m ON a.featured = m.id';
$query .= ' WHERE a.published=1';
if($this->catids) {

$query .= ' AND a.catid IN ('.implode(',', $this->catids).')';




}


if($this->catid3) {

$query .= ' AND a.catid3 IN ('.implode(',', $this->catids).')';




}


if($this->filter_location){
if($this->filter_location['active_location']) {
$query .= ' AND ( a.country='.$this->filter_location['active_location'].' OR a.region='.$this->filter_location['active_location'].')';
}
}









$query .= ' AND a.catid!=0';


switch($this->filter_order) {
case 'latest' :
$query .= ' ORDER BY a.featured DESC, TIMESTAMP(a.updateddate) DESC, TIMESTAMP(a.createddate) DESC';
break;
case 'created' :
$query .= ' ORDER BY a.featured DESC, TIMESTAMP(a.createddate) ASC';
break;
case 'price_lh' :
$query .= ' ORDER BY a.featured DESC, a.price ASC';
break;
case 'price_hl' :
$query .= ' ORDER BY a.featured DESC, a.price DESC';
break;
case 'popular' :
$query .= ' ORDER BY a.featured DESC, a.views DESC';
break;
case 'random' :
$query .= ' ORDER BY a.featured DESC, RAND()';
break;
case 'a_z' :
default :
$query .= " ORDER BY a.featured DESC, a.title ASC";
}

$db->setQuery( $query, $this->limitstart, $this->limit);
$items = $db->loadObjectList();

return $items;
}

function getLists() {
$lists = array ();
$lists['views'] = JomclHTML::ListDesignViews($this->filter_view);
$lists['orderby'] = JomclHTML::ListOrderBy($this->filter_order);

return($lists);
}

function getPagination() {
jimport( 'joomla.html.pagination' );
$pageNav = new JPagination($this->getTotal(), $this->limitstart, $this->limit);

return($pageNav);
}

function getTotal() {
$db = JFactory::getDBO();
$query = 'SELECT COUNT(a.id) FROM #__jomcl_adverts AS a';
$query .= ' WHERE a.published=1';
$query .= ' AND a.catid!=0';

if($this->catids) {
$query .= ' AND a.catid IN ('.implode(',', $this->catids).')';
}


if($this->catids3) {
$query .= ' AND a.catid3 IN ('.implode(',', $this->catids3).')';
}

if($this->filter_location){
if($this->filter_location['active_location']) {
$query .= ' AND ( a.country='.$this->filter_location['active_location'].' OR a.region='.$this->filter_location['active_location'].')';
}
}

switch($this->filter_order) {
case 'latest' :
$query .= ' ORDER BY a.featured DESC, TIMESTAMP(a.updateddate) DESC, TIMESTAMP(a.createddate) DESC';
break;
case 'created' :
$query .= ' ORDER BY a.featured DESC, TIMESTAMP(a.createddate) ASC';
break;
case 'price_lh' :
$query .= ' ORDER BY a.featured DESC, a.price ASC';
break;
case 'price_hl' :
$query .= ' ORDER BY a.featured DESC, a.price DESC';
break;
case 'popular' :
$query .= ' ORDER BY a.featured DESC, a.views DESC';
break;
case 'random' :
$query .= ' ORDER BY a.featured DESC, RAND()';
break;
case 'a_z' :
default :
$query .= " ORDER BY a.featured DESC, a.title ASC";
}

$db->setQuery( $query);
$result = $db->loadResult();

return $result;
}

}

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий