Reverse select way to show categories

Phoca Gallery plugins - plugins for Phoca Gallery extension
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Reverse select way to show categories

Post by Jan »

Hi, this is planned, for now only hiding different categories can be set :-(

Jan
If you find Phoca extensions useful, please support the project
gerardq
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 20 Sep 2010, 15:35

Re: Reverse select way to show categories

Post by gerardq »

Hello Jan,
I am looking for this option too. Do you have an idea when it will be released? At the moment I have on every group page included: '..hidecategories=1,2,3,4,5,..etc..100' and then remove the albums I want to see from that string. Not very elegant :|
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Reverse select way to show categories

Post by Jan »

Hi, still no idea when I will be able to implement it :-(

Jan
If you find Phoca extensions useful, please support the project
gerardq
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 20 Sep 2010, 15:35

Re: Reverse select way to show categories

Post by gerardq »

Hi Jan,

I realized I really needed yet another option: I am setting up a site for a primary school and all the classes are Joomla categories. They all have photo albums and I want to show previews of their own albums on each class page. So I now created empty Phoca top level categories for each class and uploaded all albums under the corresponding Phoca category.
I adhanced your code just a bit so I can specify a 'parentcategoryid'. The class pages now show only their own photo albums.
Are you interested in this tiny enhancement or shall I publish it on this forum?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Reverse select way to show categories

Post by Jan »

Hi, just publish it here so other users can see it (if they are interested in such solution). For now I am still not able to look at it :-( but there are some other users which can help :idea:

Jan
If you find Phoca extensions useful, please support the project
gerardq
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 20 Sep 2010, 15:35

Re: Reverse select way to show categories

Post by gerardq »

When view=categories, to show only categories with a certain parentid, edit the file /plugin/content/phocagallery.php like this (based on plg_content_phocagallery_2.7.2, in bold the code that has to be added ):

...
$catid = 0;
$parentcatid = 0;
...

...
else if($values[0]=='categoryid') {$catid = $values[1];}
else if($values[0]=='parentcategoryid') {$parentcatid = $values[1];}
...

...
$uniqueCatSql = '';
if ($catid > 0) {
$uniqueCatSql = ' AND cc.id = '. $catid .'';
}
$parentCatSql = '';
if ($parentcatid > 0) {
$parentCatSql = ' AND cc.parent_id = '. $parentcatid .'';
}

...

...
$queryc = 'SELECT cc.*, a.catid, COUNT(a.id) AS numlinks,'
...
. $uniqueCatSql
. $parentCatSql
. ' GROUP BY cc.id'
. ' ORDER BY cc.ordering';
...

...
$output .= '<tr>'
//to show alias and description beside the category...
if ($display_description == 1) {
.'<td style="width:500px"><b>'.$category->alias.' </b>' .$category->description.'</td>';
}

.'<td align="center" valign="middle" style="'.$imageBg.'"><a href="'.$category->link.'">';


usage: {phocagallery view=categories|parentcategoryid=4|displaydescription=1|}
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Reverse select way to show categories

Post by Jan »

Hi, thank you for this guide. Marked as improvement.

Jan
If you find Phoca extensions useful, please support the project
pix
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 16 May 2011, 13:52

Re: Reverse select way to show categories

Post by pix »

benoix wrote:Hello,
I use phoca gallery Plugin in my article to show link into my gallery.
I can choose which categories I hide but I would like to do opposite. That means I would like choose which categories I want to SHOW. Because, in example, when I show a link into one categories (I hide all the others) in an article that is ok but after if I add a new categories it will be show in my article ! It will not hide.

Wich file I have to modify to do this ?

Thank

Ben


for showing selected categories you should add only 4 lines

check the argument

Code: Select all

else if($values[0]=='showcategories')	{$show_categories		= $values[1];}

create SQL part - just add:
$showCat = trim( $show_categories );
$showCatSql .= ' AND cc.id IN ('. $showCat .') ';

Code: Select all

//--------------------------
			// DISPLAYING OF CATEGORIES (link doesn't work if there is no menu link)
			//--------------------------
			
			
			$hideCat		= trim( $hide_categories );
			$hideCatArray	= explode( ',', $hide_categories );
			$hideCatSql		= '';
			if (is_array($hideCatArray)) {
				foreach ($hideCatArray as $value) {
					$hideCatSql .= ' AND cc.id != '. (int) trim($value) .' ';
				}
			}

			$showCat		= trim( $show_categories );
			$showCatSql .= ' AND cc.id IN ('. $showCat .') ';


and add it to sql query

Code: Select all

if ($view == 'categories') {
				//CATEGORIES
				$queryc = 'SELECT cc.*, a.catid, COUNT(a.id) AS numlinks,'
				. ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as slug'
				. ' FROM #__phocagallery_categories AS cc'
				. ' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id'
				. ' WHERE a.published = 1'
				. ' AND cc.published = 1'
				. ' AND cc.approved = 1'
				. ' AND a.approved = 1'
				. $hideCatSql
				. $showCatSql
				. $uniqueCatSql
				. ' GROUP BY cc.id'
				. ' ORDER BY cc.ordering';
I just needed this option, and I was suprised that there is no code for that. Think it should be added to released plugin.
regards, Pix
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Reverse select way to show categories

Post by Jan »

Hi, thank you for the guide.
Jan
If you find Phoca extensions useful, please support the project
Post Reply