Created
April 27, 2013 21:35
-
-
Save elinw/5474827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/components/com_content/models/article.php b/components/com_content/models/article.php | |
index 081b936..205a3da 100644 | |
--- a/components/com_content/models/article.php | |
+++ b/components/com_content/models/article.php | |
@@ -55,6 +55,8 @@ | |
$this->setState('filter.published', 1); | |
$this->setState('filter.archived', 2); | |
} | |
+ | |
+ $this->setState('filter.language', JLanguageMultilang::isEnabled()); | |
} | |
/** | |
@@ -101,7 +103,7 @@ | |
// Join on user table. | |
$query->select('u.name AS author'); | |
$query->join('LEFT', '#__users AS u on u.id = a.created_by'); | |
- | |
+ | |
// Join on contact table | |
$subQuery = $db->getQuery(true); | |
$subQuery->select('contact.user_id, MAX(contact.id) AS id, contact.language'); | |
@@ -110,7 +112,14 @@ | |
$subQuery->group('contact.user_id, contact.language'); | |
$query->select('contact.id as contactid' ); | |
$query->join('LEFT', '(' . $subQuery . ') AS contact ON contact.user_id = a.created_by'); | |
- | |
+ | |
+ // Filter by language | |
+ if ($this->getState('filter.language')) | |
+ { | |
+ $query->where('a.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')'); | |
+ $query->where('(contact.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').') OR contact.language IS NULL)'); | |
+ } | |
+ | |
// Join over the categories to get parent category titles | |
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias'); | |
$query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment