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


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

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



  • Закрытая тема Тема закрыта
Сообщений в теме: 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, вот функция:

public function getItems($params) {

		$items = array();
		if ($application = $this->app->table->application->get($params->get('application', 0))) {

			// set one or multiple categories
			$category = (int) $params->get('category', 0);
			if ($params->get('subcategories')) {
				$categories = $application->getCategoryTree(true);
				if (isset($categories[$category])) {
					$category = array_merge(array($category), array_keys($categories[$category]->getChildren(true)));
				}
			}

			// get items
			if ($params->get('mode') == 'item') {
				if (($item = $this->app->table->item->get($params->get('item_id'))) && $item->isPublished() && $item->canAccess()) {
					$items[] = $item;
				}
			} else if ($params->get('mode') == 'types') {
				$items = $this->app->table->item->getByType($params->get('type'), $application->id, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
			} else {
				$items = $this->app->table->item->getByCategory($application->id, $category, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
			}
		}
		return $items;
	}

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

 

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

 

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


  • 2

#3 CB9TOIIIA

CB9TOIIIA

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

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

 

Есть строка:

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

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

 

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

	public function getItemswithoffset($params) {

		$items = array();
		if ($application = $this->app->table->application->get($params->get('application', 0))) {

			// set one or multiple categories
			$category = (int) $params->get('category', 0);
			if ($params->get('subcategories')) {
				$categories = $application->getCategoryTree(true);
				if (isset($categories[$category])) {
					$category = array_merge(array($category), array_keys($categories[$category]->getChildren(true)));
				}
			}

			// get items
			if ($params->get('mode') == 'item') {
				if (($item = $this->app->table->item->get($params->get('item_id'))) && $item->isPublished() && $item->canAccess()) {
					$items[] = $item;
				}
			} else if ($params->get('mode') == 'types') {
				$items = $this->app->table->item->getByType($params->get('type'), $application->id, true, null, $params->get('order', array('_itemname')), 0, $params->get('count', 4));
			} else {
				$items = $this->app->table->item->getByCategory($application->id, $category, true, null, $params->get('order', array('_itemname')), 3, $params->get('count', 4));
			}
		}
		return $items;
	}

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

 

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

	$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!