11
trabis
Re: problem with getAllChild
  • 2009/8/20 15:28

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Try this for index.php
<?php /** * **************************************************************************** * Module généré par TDMCreate de la TDM "http://www.tdmxoops.net" * **************************************************************************** * xsitemap - MODULE FOR XOOPS AND IMPRESS CMS * Copyright (c) Urbanspaceman (http://www.takeaweb.it) * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Urbanspaceman (http://www.takeaweb.it) * @license GPL * @package xsitemap * @author Urbanspaceman (http://www.takeaweb.it) * * Version : 1.00: * **************************************************************************** */ //Show xsitemap function xsitemap_get_map($table, $id_name, $pid_name, $title_name, $url, $order = ""){ global $sitemap_configs; $xoopsDB =& Database::getInstance(); $xsitemap = array(); $myts =& MyTextSanitizer::getInstance(); $i = 0; $sql = "SELECT `$id_name`,`$title_name` FROM ".$xoopsDB->prefix."_"."$table WHERE `$pid_name`= 0" ; if ($order != '') { $sql .= " ORDER BY `$order`" ; } $result = $xoopsDB->query($sql); while ($row = $xoopsDB->fetchArray($result)) { $objsArray[] = new XoopsDummyObject($row, $id_name, $pid_name, $title_name); } $mytree = new XoopsObjectTree($objsArray, $id_name, $pid_name); while (list($catid, $name) = $xoopsDB->fetchRow($result)) { $xsitemap['parent'][$i]['id'] = $catid; $xsitemap['parent'][$i]['title'] = $myts->htmlSpecialChars( $name ) ; $xsitemap['parent'][$i]['url'] = $url.$catid; //if($xsitemap_configs["show_subcategories"]){ $j = 0; $child_array = $mytree->getAllChild($catid); foreach ($child_array as $child) { //$count = strlen($child['prefix']) + 1; $xsitemap['parent'][$i]['child'][$j]['id'] = $child[$id_name]; $xsitemap['parent'][$i]['child'][$j]['title'] = $myts->htmlSpecialChars( $child[$title_name] ) ; //$xsitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count); $xsitemap['parent'][$i]['child'][$j]['url'] = $url.$child[$id_name]; $j++; } //} $i++; } return $xsitemap; } ?>

12
urbanspacema
Re: problem with getAllChild

mmm don't work...

if i print print_r($objsArray);
it return this

le="color: #000000"><?php Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => 2 [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria news [required] => [data_type] => 1 [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => 2 [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria news [required] => [data_type] => 1 [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) [1] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => 1 [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => XOOPS [required] => [data_type] => 1 [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( ) Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => 1 [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => 3 [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria ams [required] => [data_type] => 1 [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( )


Value for topic_pid is always empty...

13
trabis
Re: problem with getAllChild
  • 2009/8/20 16:49

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Of course, your query is not asking it.

le="color: #000000"><?php $sql = "SELECT `$id_name`, `$pid_name`, `$title_name` FROM ".$xoopsDB->prefix."_"."$table WHERE `$pid_name`= 0" ;


It needs to go on the row for the Object to work.

14
urbanspacema
Re: problem with getAllChild

fixed but the problem is not that ...
I still do not see the child

15
trabis
Re: problem with getAllChild
  • 2009/8/20 16:58

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Damn, this is hard. Since we add extra value on the query you have to fix this:
le="color: #000000"><?php while (list($catid, $pid, $name) = $xoopsDB->fetchRow($result))

16
trabis
Re: problem with getAllChild
  • 2009/8/20 17:21

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Try this:
<?php /** * **************************************************************************** * Module généré par TDMCreate de la TDM "http://www.tdmxoops.net" * **************************************************************************** * xsitemap - MODULE FOR XOOPS AND IMPRESS CMS * Copyright (c) Urbanspaceman (http://www.takeaweb.it) * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Urbanspaceman (http://www.takeaweb.it) * @license GPL * @package xsitemap * @author Urbanspaceman (http://www.takeaweb.it) * * Version : 1.00: * **************************************************************************** */ //Show xsitemap function xsitemap_get_map($table, $id_name, $pid_name, $title_name, $url, $order = ""){ global $sitemap_configs; $xoopsDB =& Database::getInstance(); $xsitemap = array(); $myts =& MyTextSanitizer::getInstance(); $sql = "SELECT `$id_name`, `$pid_name`, `$title_name` FROM ".$xoopsDB->prefix."_"."$table" ; $result = $xoopsDB->query($sql); while ($row = $xoopsDB->fetchArray($result)) { $objsArray[] = new XoopsDummyObject($row, $id_name, $pid_name, $title_name); } $mytree = new XoopsObjectTree($objsArray, $id_name, $pid_name); $i = 0; $sql = "SELECT `$id_name`, `$title_name` FROM ".$xoopsDB->prefix."_"."$table WHERE `$pid_name`= 0" ; if ($order != '') { $sql .= " ORDER BY `$order`" ; } $result = $xoopsDB->query($sql); while (list($catid, $name) = $xoopsDB->fetchRow($result)) { $xsitemap['parent'][$i]['id'] = $catid; $xsitemap['parent'][$i]['title'] = $myts->htmlSpecialChars( $name ) ; $xsitemap['parent'][$i]['url'] = $url.$catid; //if($xsitemap_configs["show_subcategories"]){ $j = 0; $child_array = $mytree->getAllChild($catid); foreach ($child_array as $child) { //$count = strlen($child['prefix']) + 1; $xsitemap['parent'][$i]['child'][$j]['id'] = $child[$id_name]; $xsitemap['parent'][$i]['child'][$j]['title'] = $myts->htmlSpecialChars( $child[$title_name] ) ; //$xsitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count); $xsitemap['parent'][$i]['child'][$j]['url'] = $url.$child[$id_name]; $j++; } //} $i++; } return $xsitemap; } ?>

Who's Online

613 user(s) are online (422 user(s) are browsing Support Forums)


Members: 0


Guests: 613


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits