ok,
I know it is a late raction, but here is the result:
http://www.derbigum.fr/produits
I had created some additional fields like
- Fiche-technique (alias TF)
- CE (alias CE)
- FDS (alias FDS)
obtained the result with an UDT written by
buildbyrobot
Note: if you renamed the module (like i did) you will need to change the table names in the queries!
Code: Select all
/**
* Generate a parentcat - subcat - product array
**/
$sql = 'SELECT category_id, category_name FROM cms_module_listit2_category WHERE parent_id = -1 ORDER BY position';
$qry = mysql_query($sql);
while ($p_cat = mysql_fetch_object($qry)){
$sql2 = 'SELECT category_id, category_name FROM cms_module_listit2_category WHERE parent_id = ' . $p_cat->category_id . ' ORDER BY position';
$qry2 = mysql_query($sql2);
if (mysql_num_rows($qry2)){
echo '<a name="#cat' . $p_cat->category_id . '"></a>';
echo '<h2 class="category-title">' . $p_cat->category_name . '</h2>';
while ($cat = mysql_fetch_object($qry2)){
$psql = 'SELECT item_id, title, alias FROM `cms_module_listit2_item` WHERE category_id = ' . $cat->category_id . ' AND active = 1 ORDER BY position';
$pqry = mysql_query($psql);
if (mysql_num_rows($pqry)){
echo '<a name="#cat' . $cat->category_id . '"></a>';
echo '<h3 class="category-title">' . $cat->category_name . '</h3>';
echo '<div class="items">';
while ($item = mysql_fetch_object($pqry)){
// get the details
$dsql = 'SELECT cms_module_listit2_fielddef.name, cms_module_listit2_fielddef.alias, cms_module_listit2_fielddef.type, cms_module_listit2_fieldval.value FROM cms_module_listit2_fielddef INNER JOIN cms_module_listit2_fieldval ON cms_module_listit2_fieldval.fielddef_id = cms_module_listit2_fielddef.fielddef_id WHERE cms_module_listit2_fieldval.item_id = ' . $item->item_id . ' ORDER BY cms_module_listit2_fielddef.position';
$dqry = mysql_query($dsql);
$dt = array(
'Description' => ' ',
'Fiche-technique' => ' ',
'CE' => ' ',
'FDS' => ' '
);
while ($do = mysql_fetch_object($dqry)){
switch ($do->alias){
case 'desc':
$key = 'Description';
break;
case 'TF':
$key = 'Fiche-technique';
break;
case 'CE':
$key = 'CE';
break;
case 'fds':
$key = 'FDS';
break;
}
$dt[$key] = $do->value;
}
echo '<div class="item">';
echo '<div class="details item-title">' . $item->title . '</div>';
foreach ($dt as $cla => $opt){
if ($cla == 'Description'){
$cla .= '';
}else{
if ($opt != ' '){
$opt = '<a href="' . $opt . '" target="_blank">' . str_replace('-', ' ', $cla) . '</a>';
}
$cla .= ' textbox';
}
echo '<div class="details ' . $cla . '">' . $opt . '</div>';
}
echo '</div>';
}
echo '</div>';
}
}
}else{
// only if we find products
$psql = 'SELECT item_id, title, alias FROM `cms_module_listit2_item` WHERE category_id = ' . $p_cat->category_id . ' AND active = 1 ORDER BY position';
$pqry = mysql_query($psql);
if (mysql_num_rows($pqry)){
echo '<a name="#cat' . $p_cat->category_id . '"></a>';
echo '<h2 class="category-title">' . $p_cat->category_name . '</h2>';
echo '<div class="items">';
while ($item = mysql_fetch_object($pqry)){
// get the details
$dsql = 'SELECT cms_module_listit2_fielddef.name, cms_module_listit2_fielddef.alias, cms_module_listit2_fielddef.type, cms_module_listit2_fieldval.value FROM cms_module_listit2_fielddef INNER JOIN cms_module_listit2_fieldval ON cms_module_listit2_fieldval.fielddef_id = cms_module_listit2_fielddef.fielddef_id WHERE cms_module_listit2_fieldval.item_id = ' . $item->item_id . ' ORDER BY cms_module_listit2_fielddef.position';
$dqry = mysql_query($dsql);
$dt = array(
'Description' => ' ',
'Fiche-technique' => ' ',
'CE' => ' ',
'FDS' => ' '
);
while ($do = mysql_fetch_object($dqry)){
switch ($do->alias){
case 'desc':
$key = 'Description';
break;
case 'TF':
$key = 'Fiche-technique';
break;
case 'CE':
$key = 'CE';
break;
case 'fds':
$key = 'FDS';
break;
}
$dt[$key] = $do->value;
}
echo '<div class="item">';
echo '<div class="details item-title">' . $item->title . '</div>';
foreach ($dt as $cla => $opt){
if ($cla == 'Description'){
$cla .= '';
}else{
if ($opt != ' '){
$opt = '<a href="' . $opt . '" target="_blank">' . str_replace('-', ' ', $cla) . '</a>';
}
$cla .= ' textbox';
}
echo '<div class="details ' . $cla . '">' . $opt . '</div>';
}
echo '</div>';
}
echo '</div>';
}
}
}