Page 1 of 1

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

Posted: 15 Nov 2011, 12:41
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

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

Posted: 18 Nov 2011, 00:45
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

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

Posted: 18 Nov 2011, 14:53
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

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

Posted: 23 Nov 2011, 16:04
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.

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

Posted: 23 Nov 2011, 18:01
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...

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

Posted: 29 Nov 2011, 15:43
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 ;-)

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

Posted: 30 Nov 2011, 16:10
by Jan
Ok