Welcome, Guest
Please Login or Register.    Lost Password?

Order alphabetical item list by Joomfish language
(1 viewing) (1) Guest
Airiny ABC Joomla extension
Go to bottomPage: 1
TOPIC: Order alphabetical item list by Joomfish language
#19
Order alphabetical item list by Joomfish language 2 Months, 3 Weeks ago  
Hi,

In alphabetical.php in com_abc (front-end) and in abc.php:
Code:


<?php
/**
 * ABC alphabetical model
 * This model gives better SEF compatibility.
 * It uses view and task CGI parameters.
 * 
 * @package     Joomla
 * @subpackage  Components
 * @link  http://www.airiny.com
 * @license     GNU/GPL
 * @version  $Id$
 * @modified      jSeblod team
 * @todo  Pagination
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
/**
 * Model for content in alphabetical order 
 * @package    Joomla
 * @subpackage Components
 */
class AbcModelAlphabetical extends JModel
{
    /**
    * Gets the greeting
    * @return string The greeting to be displayed to the user
    */
    function getArticles()
    {
    $letter = JRequest::getVar('task',  'a', '');
     $catid = JRequest::getVar('catid',  false);
     $sectionid = JRequest::getVar('sectionid',  false);
    
      $db =& JFactory::getDBO();
      $lg = &JFactory::getLanguage();
      $language = $lg->_lang;
    
     //seblod       
         jimport('joomla.application.component.helper');

            $query_lang = "select id, ordering from #__languages where code='".$language."'";
           $db->setQuery( $query_lang );
           $lang = $db->loadRow();
            $lang_id = $lang[0];
           $lang_order = $lang[1];
         
         if(JComponentHelper::isEnabled('com_joomfish', true) and $lang_order!=0)
         {
         

            $where = $catid ? " AND t2.catid = $catid" : '';
            $where .= $sectionid ? " AND t2.sectionid = $sectionid" : '';
      
            //With Joomfish
            $query = "SELECT reference_id AS id, value AS title FROM #__jf_content as t1 LEFT JOIN #__content AS t2 ON t1.reference_id = t2.id"
    ." WHERE reference_table = 'content' and reference_field = 'title' and language_id = ".$lang_id ." and published = 1"
    ."  AND UPPER(value) LIKE '$letter%'"
    .$where
    ." GROUP BY value"
    ." ORDER BY value"
    ;
            
         }else{
         //Without Joomfish
            $where = $catid ? " AND catid = $catid" : '';
          $where .= $sectionid ? " AND sectionid = $sectionid" : '';
      
             $query = "SELECT id, title FROM #__content"
    ." WHERE state = 1"
    ."  AND UPPER(title) LIKE '$letter%'"
    .$where
    ." GROUP BY title"
    ." ORDER BY title"
    ;
         }
   
    //echo "<br>DEBUG: SQL: $query";
    
   
    $db->setQuery( $query );
    $articles = $db->loadObjectList();
   
    if ($db->getErrorNum()) { //@todo log
   echo 'Error ' . $db->getErrorNum() . ': ' . $db->getErrorMsg();
}
 
    return $articles;
    

    }
}
?>



Will be great to include this in the new version.

Best Regards.
jSeblod
Fresh Boarder
Posts: 2
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Moderators: irinka, staff