Jump to content
View in the app

A better way to browse. Learn more.

IPBMafia.ru - поддержка Invision Community, релизы, темы, плагины и приложения

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Фалы из подкатегорий доунлодс

Featured Replies

Posted

Это код плагина  Файлы подкатегорий Downloads

   {{$files = array(); $category = \IPS\downloads\Category::loadAndCheckPerms(\IPS\Request::i()->id); $cids = array_map(function($c) { return $c->_id; }, $category->children());}}
		{{$cheTable = new \IPS\Helpers\Table\Content('\IPS\downloads\File', $category->url(), array(\IPS\Db::i()->in('file_cat', $cids)));}}
		    {{$cheTable->limit = \IPS\Settings::i()->che_count;}}
		{{if (count($cids))}}
			{{$files = iterator_to_array(\IPS\downloads\File::getItemsWithPermission(array(\IPS\Db::i()->in('file_cat', $cids)), 'file_submitted DESC' ));}}
		{{endif}}
    <div class='ipsBox ipsSpacer_top'>
	    <div class='ipsPad_half'>
		{{if (count($files))}}
			<ul class='che_resub_cat' data-role='tableRows'>
          {$cheTable|raw}
			</ul>
		{{else}}
			<p class='ipsType_reset ipsType_light ipsPad'>{lang="che_no_files_in_subcat"}</p>
		{{endif}}
	    </div>
    </div>

$cids = array_map(function($c) { return $c->_id; }, $category->children()); - отвечает за выборку категорий из которых показывать файлы, но этот вариант работает таким образом, что показывает файлы только из прямой связи родитель - ребенок, т.е. если:

Категория
   Подкатегория 1
      файл 1
      файл 2
   Подкатегория 2

в Категория файлы будут отображаться из подкатегорий 1 и 2,

Но, если файлы расположены глубже 2ого уровня, то файлы не отображаются, т.е.:

Категория
   Подкатегория 1
       ПодПодкатегория1
          файл 1
         файл 2
      ПодПодкатегория2

При такой структуре файлы из подкатегорий будут показаны только в Подкатегория1, а в Категория файлы уже не отображаются.

Собственно вопрос, каким образом рекурсивно получить все дочерние категории?

  • Author

Если кому-то интересно

Спойлер

	public function categoryChild()
	{
		$cids = array();

		$cids[] = $this->_id;

		if ($this->hasChildren())
		{
			$allChildren = function($cat) use (&$allChildren) {
				$ids = array();

				if ($cat->hasChildren())
				{
					foreach ($cat->children() as $child)
					{
						$ids[] = $child->_id;

						if ($child->hasChildren())
						{
							$ids = array_merge($ids, $allChildren($child));
						}
					}
				}

				return $ids;
			};

			$cids = array_merge($cids, $allChildren($this));
		}

		return $cids;
	}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Ответить в этой теме...

Последние посетители 0

  • No registered users viewing this page.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.