/** * @return JDatabaseQuery */ function getListQuery() { // Set the archive ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $categoryOrderby = ''; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive $query->select(' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'); $query->select(' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug'); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where('MONTH(' . $queryDate . ') = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where('YEAR(' . $queryDate . ') = ' . $year); } //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Get the master query for retrieving a list of articles subject to the model state. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { $params = $this->state->params; $articleOrderDate = $params->get('order_date'); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive // Sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id . ' END as catslug'; $query->select($case_when); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where($query->month($queryDate) . ' = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where($query->year($queryDate) . ' = ' . $year); } return $query; }
protected function getListQuery() { $db = $this->getDbo(); $query = parent::getListQuery(); if(strpos((string)$query->__get('select'), 'introtext') === false) { $query->select('a.'. $db->qn('introtext')); } // $query->select('CASE WHEN CHAR_LENGTH(a.'. $db->qn('introtext').') > 0 THEN a.' // . $db->qn('introtext'). ' ELSE a.'. $db->qn('fulltext'). ' END AS description'); return $query; }
/** * @return JDatabaseQuery */ protected function getListQuery() { // Set the archive ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $categoryOrderby = ''; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id . ' END as catslug'; $query->select($case_when); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where('MONTH(' . $queryDate . ') = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where('YEAR(' . $queryDate . ') = ' . $year); } //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Get the master query for retrieving a list of articles subject to the model state. * * @return JDatabaseQuery * * Change Access level from `protected` to `public` for Joomla! 2.5.x. In Joomla! 3.x must be `protected` */ public function getListQuery() { // Create a new query object. $query = parent::getListQuery(); // Filter Fieldsandfilters itemsID $itemsID = (array) $this->getState('fieldsandfilters.itemsID'); $emptyItemsID = $this->setState('fieldsandfilters.emptyItemsID', false); if (!empty($itemsID) && !$emptyItemsID) { JArrayHelper::toInteger($itemsID); $query->where($this->getDbo()->quoteName('a.id') . ' IN( ' . implode(',', $itemsID) . ')'); } if ($this->getState('fieldsandfilters.random.selected', false)) { $query->clear('order'); $query->order('RAND() ASC'); if ($this->getState('fieldsandfilters.random.limit')) { $this->setState('list.limit', $this->getState('fieldsandfilters.random.limit', 0)); } } return $query; }
/** * Get the list of items. * * @return JDatabaseQuery */ protected function getListQuery() { // Set the blog ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Filter by frontpage. if ($this->getState('filter.frontpage')) { $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id'); } // Filter by categories $featuredCategories = $this->getState('filter.frontpage.categories'); if (is_array($featuredCategories) && !in_array('', $featuredCategories)) { $query->where('a.catid IN (' . implode(',', $featuredCategories) . ')'); } return $query; }
/** * Get the list of items. * * @return JDatabaseQuery */ protected function getListQuery() { // Create a new query object. $query = parent::getListQuery(); // Filter by categories $featuredCategories = $this->getState('filter.frontpage.categories'); if (is_array($featuredCategories) && !in_array('', $featuredCategories)) { $query->where('a.catid IN (' . implode(',', $featuredCategories) . ')'); } return $query; }