Page 1 of 1

Display only selected categories

Posted: 17 May 2010, 05:07
by dr.archik
Jan hello! Help mу please, I need to add new function but it works not completely!
Image
In file www\components\com_phocagallery\views\categories\view.html.php

add in line 51:

Code: Select all

		$showCatArray	 = explode( ';', trim( $params->get( 'show_categories', '' ) ) );
Also has added necessary condition in line 115:

Code: Select all

	//"!empty$showCatArray[0]" -  Because "$hideCatArray" - I consider it is not correct .		
if (!empty($showCatArray[0]) && is_array($showCatArray)) {
				$unSetHCA = 0;
				foreach ($showCatArray as $valueHCA) {
					if((int)trim($valueHCA) != $items[$key]->id) {  // Has changed only equal-sign
						unset($items[$key]);
						$unSet 		= 1;
						$unSetHCA 	= 1;
						break;
					}
				}
				if ($unSetHCA == 1) {
					continue;
				}
			}
Problem: when in the administrative panel I specify one category id all it works and category shown on front, but when I specify a not one and the several id (13;17) - the white screen on front site

What do I do not so?
PS: I will be very grateful!

Re: Display selected categories

Posted: 17 May 2010, 13:48
by Jan
Hi, if you are programming something, you need to enable error reporting to get possible error message (e.g. error in the code), see:

https://www.phoca.cz/documents/16-joomla ... rs-on-site

Now it is works !!!

Posted: 18 May 2010, 04:56
by dr.archik
Hello "Jan", It again Arthur, from the same country :lol: ).
I want that you have added one more solution in the following version Phoca Gallery, and mark is - [Improvement]

Display selected categories
What it is necessary to do ?!:
1) File www\administrator\components\com_phocagallery\config.xml

Code: Select all

<param name="show_categories" type="phocatextarea" rows="2" cols="26" default="" label="Show Categories" description="Show Categories DESC" />
warning - It is impossible to fill fields in common (Hide categories and Show categories )
"I can't block one field in the administrative panel when fill another" - But it is not compulsory!

2) www\components\com_phocagallery\views\categories\view.html.php
Add after 50 line

Code: Select all

$showCatArray	= explode( ';', trim( $params->get( 'show_categories', '' ) ) );
Add on 131 line new condition:

Code: Select all

		// Set only selected category ID 	

 //"!empty$showCatArray[0]" -  Because "!empty$hideCatArray" - I consider it is not correct . 
                         if (!empty($showCatArray[0]) && is_array($showCatArray)) {
				$unSetHCA = 0;
			
				foreach ($showCatArray as $valueHCA) {
				
					if((int)trim($valueHCA) == $items[$key]->id) {
					$unSetHCA = 0;
					$unSet = 0;
					break;
					} else {
                    $unSetHCA = 1;
				    $unSet = 1;
					       }

				    }
					if ($unSetHCA == 1) {
					unset($items[$key]);
					continue;
					}
			}
3) Edit Lang. file :
To add at the very bottom

Code: Select all

SHOW CATEGORIES=Show Categories
SHOW CATEGORIES DESC=Set categories (categories id), which will be displayed in the categories tree, other categories will be hidden (in Categories View). Separate each id with semicolon (;)

Re: Display only selected categories

Posted: 18 May 2010, 11:29
by Jan
Hi, did you check the correctly loading of the categories because of category tree?

Re: Display only selected categories

Posted: 18 May 2010, 12:06
by dr.archik
Jan wrote:Hi, did you check the correctly loading of the categories because of category tree?
Of course!!! I tell what is it working solution!

Re: Display only selected categories

Posted: 18 May 2010, 14:52
by Jan
:| Ok I will implement it into the 2.7.1

Jan

Re: Display only selected categories

Posted: 18 May 2010, 16:53
by dr.archik
Jan wrote::| Ok I will implement it into the 2.7.1

Jan
Excellent!!! thanks ...

Re: Display only selected categories

Posted: 30 May 2010, 15:21
by Jan
Implemented.

Jan