Create a categories menu Create a categories menu
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Create a categories menu

Started by AzorMachine, September 06, 2011, 04:48:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AzorMachine

I wanna create a vertical menu that contains all of the categories of my gallery. Any code tips?

Αndré

You need to query the database to get the categories. Something like
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CATEGORIES']}");
$categories = cpg_db_fetch_rowset($rowset);
mysql_free_result($result);

should return you the whole categories table.

AzorMachine

Quote from: Αndré on September 06, 2011, 05:08:18 PM
You need to query the database to get the categories. Something like
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CATEGORIES']}");
$categories = cpg_db_fetch_rowset($rowset);
mysql_free_result($result);

should return you the whole categories table.

And how can I call it, if the template base is an .html file, and don't supports php?

Αndré

I suggest that you start to read the docs now to understand how the template system works in Coppermine.

AzorMachine

Quote from: Αndré on September 06, 2011, 05:08:18 PM
You need to query the database to get the categories. Something like
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CATEGORIES']}");
$categories = cpg_db_fetch_rowset($rowset);
mysql_free_result($result);

should return you the whole categories table.

Ok, that way the categories table is stocked. How to 'echo' it? How would stay the php code?

Best Regards

Αndré

Something like
Code (http://de2.php.net/manual/en/control-structures.foreach.php) Select
foreach ($categories as $key => $category) echo $category['name']
should work (not tested).

AzorMachine

Did this using html to show an static categories menu. No problem at all as there won't be a new categorie.
Thanks for the help.