we:category ordering

basic functions and we:tags
Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

we:category ordering

Beitragvon Michael_S » Do 1. Nov 2007, 18:49

Hi, is there a way to show categories in ascending or descending order when using we:category?

Thanks,

Michael.
Production Area
London, UK
http://productionarea.com

Benny Johnson
Member
Beiträge: 89
Registriert: Fr 10. Mär 2006, 14:15

Beitragvon Benny Johnson » Mi 21. Nov 2007, 11:22

Hi Michael,

it is not possible to sort the categories with the wE:Tag, but there is a php script that allows you to display the categories. You should be able to alter the SQL querie accordingly.

Here's the code:

<?php
$a_Categories = array();
$out = (string) '';
$docID = (int) $GLOBALS['we_doc']->ID;
// read out all category IDs for the current document
$docCats = (string) f("SELECT Category FROM ".FILE_TABLE." WHERE ID = '$docID'",'Category',$GLOBALS['DB_WE']);
// part string and write it into an array
$a_cats = explode(',', $docCats);
// remove leading and last comma
$a_cats = array_slice($a_cats, 1, -1);
// display values for each array-entry
$a_Categories = array();
foreach($a_cats as $key => $value)
{
$a_result = (array) getHash("SELECT Category,Path FROM ".CATEGORY_TABLE." WHERE ID = '".$value."'",$GLOBALS['DB_WE']);
$a_Categories[$key]['Name'] = (string) $a_result['Category'];
$a_Categories[$key]['Path'] = (string) $a_result['Path'];
}
// p_r($a_Categories); /* Debug-display */
$out = (string) '';
foreach($a_Categories as $key => $value)
{
$out .= 'Name: ' . $a_Categories[$key]['Name'] . '
';
$out .= 'Pfad + Name: ' . $a_Categories[$key]['Path'] . '
';
$out .= '<hr />';
}
echo $out;
?>

I hope this helps.
Mit freundlichen Grüssen,

Benny Johnson
Support Engineer

Living-e AG


Zurück zu „Creating templates“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 6 Gäste