Page 1 of 2

Disable phoca search for some categories

Posted: 09 Dec 2019, 10:31
by sapo
i'd like to disable the search for some categories. How can i do this? Thanks for helping

Re: Disable phoca search for some categories

Posted: 10 Dec 2019, 16:37
by Jan
Hi, there is no such option, so this needs to be customized directly in the code:

plugins\search\phocagallery\phocagallery.php

Jan

Re: Disable phoca search for some categories

Posted: 10 Dec 2019, 22:26
by sapo
Hi Jan
can you give me a example to disable categories 10 and 16. Witch part of phocagallery.php i have to change?
Thanks a lot

Re: Disable phoca search for some categories

Posted: 12 Dec 2019, 15:37
by Jan
Hi, you need to change the SQL query so e.g. add:

$wheres2[] = ' (c.id <> 10 AND c.id <> 16)';

But will be different for different SQL commands there.

Jan

Re: Disable phoca search for some categories

Posted: 13 Dec 2019, 09:13
by sapo
Thanks.
i was not able to bring in a workable version, i'm not fit on php and SQL.
But, when change the query line 177 to the categories that i want to search, is this a solution?
i mean not excluding, i mean including, search only in categories 1, 5, 15
Line 177 is
$query->from('#__phocagallery_categories AS a');
Is this the right place?
Can you make a example for searching in categories 1, 5 15?
Thanks a lot

Re: Disable phoca search for some categories

Posted: 16 Dec 2019, 17:35
by Jan
Hi, I didn't do such modification yet, so unfortunatelly I don't have any examples. But it is just standard SQL command, so you can include or exclude the categories, like you need "IN(1,5,15)" or "NOT IN(1,5,15)"

Jan

Re: Disable phoca search for some categories

Posted: 05 Jan 2020, 16:55
by sapo
Hi Jan
i tried but i was not able to get a working version.
Can you help me please? Just make a example include or exclude 2 categories, thanks
This is the part from original file from plugins\search\phocagallery\phocagallery.php
Thanks for helping

Code: Select all

		// Categories
		// - - - - - -
		$query	= $db->getQuery(true);
		$query->select('a.id, a.title AS title, a.alias, a.date AS created, a.access, a.accessuserid, t.id as tagid, t.title as tagtitle, t.alias as tagalias,'
		. ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,'
		. ' a.description AS text,'
		. ' CONCAT_WS( " / ", '.$db->quote($section).', a.title ) AS section,'
		. ' "2" AS browsernav');
		$query->from('#__phocagallery_categories AS a');
		//$query->innerJoin('#__categories AS c ON c.id = a.catid');
		//$query->where('('.$where.')' . ' AND a.state in ('.implode(',',$state).') AND  a.published = 1 AND a.approved = 1 AND  a.access IN ('.$groups.')');


		$query->leftJoin('#__phocagallery_tags_ref AS tr ON tr.imgid = a.id');
		$query->leftJoin('#__phocagallery_tags AS t ON t.id = tr.tagid');
		$query->where('('.$where.')' . ' AND  a.published = 1 AND a.approved = 1 AND  a.access IN ('.$groups.')');
		$query->group('a.id');
		$query->order($orderC);

		// Filter by language
		if ($app->isClient('site') && $app->getLanguageFilter()) {
			$tag = JFactory::getLanguage()->getTag();
			$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
			//$query->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
		}

		$db->setQuery( $query, 0, $limit );
		$listCategories = $db->loadObjectList();
		$limit -= count($listCategories);



		if(isset($listCategories)) {
			foreach($listCategories as $key => $value) {

				// USER RIGHT - ACCESS - - - - - - - - - - -
				$rightDisplay = 1;//default is set to 1 (all users can see the category)

				if (!empty($value)) {
					$rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $value->accessuserid, $value->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), $display_access_category);
				}
				if ($rightDisplay == 0) {
					unset($listCategories[$key]);
				} else {
					$listCategories[$key]->href = $link = JRoute::_(PhocaGalleryRoute::getCategoryRoute($value->id, $value->alias));
				}
				// - - - - - - - - - - - - - - - - - - - - -
			}
		}
		$rows[] = $listCategories;


Re: Disable phoca search for some categories

Posted: 09 Jan 2020, 20:54
by Jan
Hi, to include or exclude some items in sql query, IN is used:

$wheres2[] = 'a.id IN(1,2)';// only 1 or 2 catid will be selected
$wheres2[] = 'a.id NOT IN (3,4)';// all excepct categories 3 and 4 will be selected

Jan

Re: Disable phoca search for some categories

Posted: 19 Jan 2020, 21:46
by sapo
Hi Jan
thanks.
whene i put
$wheres2[] = 'a.id NOT IN (16,17,21,22,23,24,25,26,27,28,29,30,31)';
on line 161, i get a empty picture from all excluded categories on top.
But i'm not able to get a working version. Tried to put it on various places in the file, no way found.
Do you have a working version to compare for me?
Thanks a lot

Re: Disable phoca search for some categories

Posted: 19 Jan 2020, 23:24
by Jan
Hi, unfortunately, I didn't do such modification yet, so all the advices are just advices without testing :-(

Jan