[Solved] displaying category name in no-popup detail view

Phoca Gallery - image gallery extension
meisterlampe
Phoca Member
Phoca Member
Posts: 12
Joined: 07 Jun 2011, 11:21

[Solved] displaying category name in no-popup detail view

Post by meisterlampe »

hi there,

first of all, my knowledge of php/mysql is limited, that's why i have to ask.

i want to display the name of the relevant category in the detail view (no-popup).
i could implement image-title and the category id with following code:

Code: Select all

echo '<h1>'.$this->item->title.'</h1>';
echo '<h1>'.$this->item->catid.'</h1>';
this works.

but of course i don't want to show the catid. i need the real category name.
but i don't know, how i have to readout from database.

Maybe there is someone how could give me a short help.

greets and thanks
Last edited by meisterlampe on 30 Nov 2011, 16:18, edited 3 times in total.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49150
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: php code -> displaying category name in no-popup detail

Post by Jan »

Hi, print all item variables:

Code: Select all

echo '<h1>';
print_r($this->item);
echo '</h1>';
to get info where the category title is stored.

Jan
If you find Phoca extensions useful, please support the project
meisterlampe
Phoca Member
Phoca Member
Posts: 12
Joined: 07 Jun 2011, 11:21

Re: php code -> displaying category name in no-popup detail

Post by meisterlampe »

Hi Jan,

thanx for your reply.

The problem is that the name of the category isn't in the MySQL Table: *_phocagallery
The category title is stored in *_phocagallery_categories table.

I can only display the item variables of *_phocagallery. This is not as difficult.
My problem is the connection between these twice SQL-tables (in cause it has to with the catid).
But how can i get the category title from *phocagallery_categories with the catid from *_phocagallery?

Greets
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49150
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: php code -> displaying category name in no-popup detail

Post by Jan »

Hi, the catid title should be stored in the $this->item object. If not, the sql query needs to be customized to get the title from category (with left join other table). But I think, it is there as the left join should be used there.
If you find Phoca extensions useful, please support the project
meisterlampe
Phoca Member
Phoca Member
Posts: 12
Joined: 07 Jun 2011, 11:21

Re: php code -> displaying category name in no-popup detail

Post by meisterlampe »

Thanks Jan,

the cattitle isn't in $this->item object,
than i have to do it with left join.
I will try it later, when i have studied something about "left join" (never heard before).
Try and error...
meisterlampe
Phoca Member
Phoca Member
Posts: 12
Joined: 07 Jun 2011, 11:21

Re: php code -> displaying category name in no-popup detail

Post by meisterlampe »

Hi,

I've done it, yeah!
If someone needs it, here is my code:

Code: Select all

SELECT bbz3u_phocagallery.catid as catid, bbz3u_phocagallery_categories.id as id, bbz3u_phocagallery_categories.title as title
FROM bbz3u_phocagallery
LEFT JOIN bbz3u_phocagallery_categories
ON  bbz3u_phocagallery_categories.title 
WHERE  bbz3u_phocagallery_categories.id = '.$this->item->catid.'
GROUP BY bbz3u_phocagallery_categories.title'
;
I don't know if it is right coded but it works ;-)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49150
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [SOLVED] displaying category name in no-popup detail vie

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply