Перейти к содержимому


Фотография
- - - - -

Начать с... или точка отсчета модуля



  • Закрытая тема Тема закрыта
Сообщений в теме: 3

#1 CB9TOIIIA

CB9TOIIIA

Отправлено 19 November 2015 - 21:50

Всем привет, кто-нибудь делал точку отсчета в модуле? Например отображать тизеры со второй статьи или с 8 статьи. Для jbzoo oem & Zoo item.
  • 0

#2 fiction13

fiction13

Отправлено 20 November 2015 - 06:20

В модуле Zoo Item итемы берутся из хелпера Module, вот функция:

  1. public function getItems($params) {
  2.  
  3. $items = array();
  4. if ($application = $this->app->table->application->get($params->get('application', 0))) {
  5.  
  6. // set one or multiple categories
  7. $category = (int) $params->get('category', 0);
  8. if ($params->get('subcategories')) {
  9. $categories = $application->getCategoryTree(true);
  10. if (isset($categories[$category])) {
  11. $category = array_merge(array($category), array_keys($categories[$category]->getChildren(true)));
  12. }
  13. }
  14.  
  15. // get items
  16. if ($params->get('mode') == 'item') {
  17. if (($item = $this->app->table->item->get($params->get('item_id'))) && $item->isPublished() && $item->canAccess()) {
  18. $items[] = $item;
  19. }
  20. } else if ($params->get('mode') == 'types') {
  21. $items = $this->app->table->item->getByType($params->get('type'), $application->id, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
  22. } else {
  23. $items = $this->app->table->item->getByCategory($application->id, $category, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
  24. }
  25. }
  26. return $items;
  27. }

Итемы берутся в зависимости от настроек из категорий или типов.

 

0 в функциях getByType и getByCategory и означает Вашу точку отсчета, offset.

 

Можно добавить дополнительный параметр в модуле и изменить хелпер, можно повторить эту функцию в модуле.


  • 2

#3 CB9TOIIIA

CB9TOIIIA

Отправлено 20 November 2015 - 08:25

Отлично :) вопрос...

 

Есть строка:

  1. $items = $zoo->module->getItemswithoffset($params);

Она обращается к модулю в 

 

C:\OpenServer\domains\test.local\administrator\components\com_zoo\helpers\module.php

  1. public function getItemswithoffset($params) {
  2.  
  3. $items = array();
  4. if ($application = $this->app->table->application->get($params->get('application', 0))) {
  5.  
  6. // set one or multiple categories
  7. $category = (int) $params->get('category', 0);
  8. if ($params->get('subcategories')) {
  9. $categories = $application->getCategoryTree(true);
  10. if (isset($categories[$category])) {
  11. $category = array_merge(array($category), array_keys($categories[$category]->getChildren(true)));
  12. }
  13. }
  14.  
  15. // get items
  16. if ($params->get('mode') == 'item') {
  17. if (($item = $this->app->table->item->get($params->get('item_id'))) && $item->isPublished() && $item->canAccess()) {
  18. $items[] = $item;
  19. }
  20. } else if ($params->get('mode') == 'types') {
  21. $items = $this->app->table->item->getByType($params->get('type'), $application->id, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
  22. } else {
  23. $items = $this->app->table->item->getByCategory($application->id, $category, true, null, $params->get('order', array('_itemname')), 3, $params->get('count', 4));
  24. }
  25. }
  26. return $items;
  27. }
  28.  

Возможно ли эту функцию корректно вписать в модуль? или она должна быть именно в том пути?

 

Просто не понимаю если функцию в модуль прописать как вызов то сделать:

  1. $items = $zoo->module->getItemswithoffset($params);

  • 0

#4 CB9TOIIIA

CB9TOIIIA

Отправлено 20 November 2015 - 10:07   Лучший Ответ

http://forum.jbzoo.c...chkoj-otscheta/


  • 1




Click to return to top of page in style!