Subcategories sort by id

Phoca Gallery - image gallery extension
Balazs
Phoca Member
Phoca Member
Posts: 13
Joined: 17 Nov 2008, 16:49

Subcategories sort by id

Post by Balazs »

Hello,

I have a problem: How can i make phoca gallery sort subcategories by id reverse? I want the subcategory width the largest id to be at the first place. Which file i need to edit and how?

Thx for help!

Balazs
Last edited by Balazs on 16 Jan 2009, 11:14, edited 1 time in total.
User avatar
caro84g
Phoca Hero
Phoca Hero
Posts: 1369
Joined: 11 Feb 2008, 17:52
Location: Holland
Contact:

Re: Subcategories sort

Post by caro84g »

Hi,

go in the backend to categories. Change the order of your subcategories by typing the right number in the boxes. Press the floppy image on top of this row.

It's just like you save the order of menu-items in Joomla!

Regards, Carolien
Please ask your support questions in the forums and not via PM - I delete those PM's
Backup before you do any major change to your website (and test first)
Balazs
Phoca Member
Phoca Member
Posts: 13
Joined: 17 Nov 2008, 16:49

Re: Subcategories sort

Post by Balazs »

Hi,

I got at least 4000-5000 subcategories, it would take very long time. I could modify the order of the main categories by editing the view file of the mvc. How can i do the same thing width subcategires? Which file contains the code which sorts the subcategories?

Regarsd, Balazs
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Re: Subcategories sort

Post by zocha »

Balazs wrote:I got at least 4000-5000 subcategories, it would take very long time. I could modify the order of the main categories by editing the view file of the mvc.
Wouldn't be easier to update the value of order column directly in db? Something like creating temporary table with category_id and max_ordering columns then:

Code: Select all

INSERT INTO temp
SELECT parent_id, max(ordering)
FROM jos_phocagallery_categories
GROUP BY parent_id;

UPDATE jos_phocagallery_categories, temp
SET jos_phocagallery_categories.ordering=temp.max_ordering - jos_phocagallery_categories.ordering
WHERE jos_phocagallery_categories.parent_id=temp.category_id
So new value of ordering would be the maximum in the category - current value.

Not tested. Do some tests with copied jos_phocagallery_categories table.
Łukasz Indeka
Joomla VirtueMart
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Re: Subcategories sort by id

Post by zocha »

Or even simplier:

Code: Select all

UPDATE jos_phocagallery_categories
SET jos_phocagallery_categories.ordering=100000000 - jos_phocagallery_categories.id
where 100000000 would be maximum id value or just something very big.
Łukasz Indeka
Joomla VirtueMart
Balazs
Phoca Member
Phoca Member
Posts: 13
Joined: 17 Nov 2008, 16:49

Re: Subcategories sort by id

Post by Balazs »

Hi,

I solved the problem. I edited the view part of the component to read and show the items backward instead of forward.
In the /.../views/category/tmpl/default.php file I deleted the line 75, and write in the following:

for($key = count($this->items) - 1; $key >= 0; $key--) {
$value = $this->items[$key];

instead of this: foreach($this->items as $key => $value) {

It works fine.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Subcategories sort by id

Post by Jan »

ok
If you find Phoca extensions useful, please support the project
Qbik
Phoca Member
Phoca Member
Posts: 44
Joined: 22 Feb 2008, 13:32
Location: Poland
Contact:

Re: Subcategories sort by id

Post by Qbik »

So what exactly I have to change to add possibility or to change direction of shoving category (newest first)

on line 75
I Have
$iconBoxWidth = 0;
Post Reply