All questions about EDocman extension

Documents Module - Ordering

  • Paddy Wanless
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 6 months ago #19693 by Paddy Wanless
Documents Module - Ordering was created by Paddy Wanless
Hi,

I ideally want to be able to create a module that shows all of the documents in a specific category. I also want to be able to sort the results.

At the moment I am using the Documents module - selecting the Latest Downloads, choosing a high number of downloads so that it shows all documents in that category, and it works.

The only issue that I have is that I would like it to sort the documents by Title, similar to the option I specify for the component view.

Is this possible? and is there a better way to show all documents in a category in a module?

Thanks in advance,

Paddy

Please Log in or Create an account to join the conversation.

  • Paddy Wanless
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 6 months ago #19708 by Paddy Wanless
Replied by Paddy Wanless on topic Re: Documents Module - Ordering
Hi, I just wanted to update you and let you know that I have managed to fix this myself.

I modified the modules\mod_edocman_documents\mod_edocman_documents.php file to change the sort order for case 1 (latest) to title.

Works like a dream.

Thanks, Paddy

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #19758 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Documents Module - Ordering
Thanks Paddy for the information. Could you please upload the modified version of the module here so that if someone needs it, they can use it ?

Regards.

Tuan

Please Log in or Create an account to join the conversation.

  • Paddy Wanless
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 6 months ago - 11 years 6 months ago #19770 by Paddy Wanless
Replied by Paddy Wanless on topic Re: Documents Module - Ordering
Hi Tuan,

Great idea - I have shown the modified mod_edocman_documents.php file to this post.

Thanks, Paddy
Code:
<?php /** * @version 1.0.0 * @package Joomla * @subpackage Edocman * @author Tuan Pham Ngoc * @copyright Copyright (C) 2011 Ossolution Team * @license GNU/GPL, see LICENSE.php */ defined('_JEXEC') or die ('Restricted access'); require_once JPATH_ADMINISTRATOR.'/components/com_edocman/helpers/edocman.php'; EdocmanHelper::loadLanguage(); $db = & JFactory::getDBO(); $user = & JFactory::getUser() ; $itemId = (int) $params->get('item_id'); if (!$itemId) $itemId = EdocmanHelper::getItemid(); $numberDocuments = $params->get('number_documents', 6); $categoryIds = $params->get('category_ids', ''); $type = $params->get('module_type', 1); $where = array() ; $where[] = 'a.published =1 ' ; $where[] = 'a.access IN ('.implode(',', $user->getAuthorisedViewLevels()).')' ; if ($categoryIds != '') { $where[] = ' a.id IN (SELECT document_id FROM #__edocman_document_category WHERE category_id IN ('.$categoryIds.'))' ; } $sql = 'SELECT a.id, a.title, a.filename, a.hits, a.downloads FROM #__edocman_documents AS a WHERE '.implode(' AND ', $where) ; switch ($type) { case 1 : $sql .= ' ORDER BY a.title ASC, a.ordering ' ; $layout = 'lastest'; break ; case 2 : $sql .= ' ORDER BY a.hits DESC, a.ordering ' ; $layout = 'top_hits' ; break ; case 3 : $sql .= ' ORDER By a.downloads DESC ' ; $layout = 'top_downloads'; break ; } $sql .= ' LIMIT 0, '.$numberDocuments ; $db->setQuery($sql) ; $rows = $db->loadObjectList(); require(JModuleHelper::getLayoutPath('mod_edocman_documents', $layout)); ?>
Last edit: 11 years 6 months ago by Paddy Wanless.

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #19796 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Documents Module - Ordering
Great, thanks Paddy for sharing the code .

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Mr. Dam