4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: MRJEE on November 27, 2005, 06:03:44 PM

Title: Full category list on each page ???
Post by: MRJEE on November 27, 2005, 06:03:44 PM
Hello!

Help me please. I need to see the full list of categories on each page (not drop down form).

Title: Re: Full category list on each page ???
Post by: MRJEE on November 28, 2005, 10:43:06 AM
Dear users, help me. I can not understand what to do. How to make the full list of categories on all pages.
Помогите сделать полный список категорий на всех станицах сайта.


Flowers  [2 images]       full, macro...
Nature [5 images]         winter, summer...   
Title: Re: Full category list on each page ???
Post by: mawenzi on November 28, 2005, 12:16:40 PM
hi MRJEE,

take this ...

Full category list on each page

open includes/page_header.php and add right before ?> :
Code: [Select]
//-----------------------------------------------------
//--- Full category list on each page ---
//-----------------------------------------------------
$full_category_list = "";
$sql = "SELECT cat_images, cat_name, cat_id, cat_description FROM ".CATEGORIES_TABLE." ORDER BY cat_id ASC";
$result = $site_db->query($sql);
$max_out = 15; //max letters for description, but whole words are shown !
$full_category_list .= '<table border="0" cellspacing="0" cellpadding="0">';
while ($row = $site_db->fetch_array($result)) {
$cat_description = format_text($row['cat_description'],1);
$cat_description_short = (strlen($cat_description)>$max_out) ? substr($cat_description,0,$max_out). substr(substr($cat_description,$max_out),0,strpos(substr($cat_description,$max_out)," "))." ..." : $cat_description;
$full_category_list .= '<tr><td><b><a href ="'.$site_sess->url(ROOT_PATH.'categories.php?cat_id='.$row['cat_id']).'">'.$row['cat_name'].'</a></b> [ '.$row['cat_images'].' images ]&nbsp;&nbsp;</td><td>'.$cat_description_short.'</td></tr>';
}
$full_category_list .= '</table>';
$site_template->register_vars("full_category_list", $full_category_list);
unset($full_category_list);
//-----------------------------------------------------

Now you can use for your category list in each main template :
Code: [Select]
{full_category_list}

thats all ...  :wink: ... I hope I could help
mawenzi
Title: Re: Full category list on each page ???
Post by: V@no on November 28, 2005, 02:53:07 PM
Dont forget we have all categories cached in $cat_cache array, basicaly no need query database again ;)
Title: Re: Full category list on each page ???
Post by: koikonut on April 20, 2006, 05:51:17 AM
Dont forget we have all categories cached in $cat_cache array, basicaly no need query database again ;)

Then, how would a category list look?

Is it possible to include a category-list from another page too? e.g. from www.domain.com/index.php a file called www.domain.com/gallery/cat_list.php or something like that?

Thx for helping! Bye Konradin
Title: Re: Full category list on each page ???
Post by: JensF on April 21, 2006, 10:50:51 AM
Wollte das eben mal testen um zu schauen wie es aussieht aber ich bekomme immer folgende Meldung

DB Error: Bad SQL Query: SELECT cat_images, cat_name, cat_id, cat_description FROM bildergalerie_categories ORDER BY cat_id ASC
Unknown column 'cat_images' in 'field list'

Habe auch nachgeschaut und ich habe gar kein cat_images Feld :(


*EDIT*

OK, habe einfach cat_images aus dem page_header Code entfernt und nun geht es. Aber ne Drop Down Liste ist mir dann doch lieber :) Ist doch alles ein wenig to big dann....