xoops forums

Forum Index


Board index » All Posts (urbanspacema)




urbanspacema

Quite a regular
Posted on: 2009/8/20 16:56
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#31

Re: problem with getAllChild

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


urbanspacema

Quite a regular
Posted on: 2009/8/20 16:40
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#32

Re: problem with getAllChild

mmm don't work...

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

Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria news [required] => [data_type] => [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria news [required] => [data_type] => [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) [1] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => XOOPS [required] => [data_type] => [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( ) Array ( [0] => XoopsDummyObject Object ( [vars] => Array ( [topic_id] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_pid] => Array ( [value] => [required] => [data_type] => [maxlength] => [changed] => [options] => ) [topic_title] => Array ( [value] => Categoria ams [required] => [data_type] => [maxlength] => [changed] => [options] => ) ) [cleanVars] => Array ( ) [_isNew] => [_isDirty] => [_errors] => Array ( ) [_filters] => Array ( ) ) ) Array ( )


Value for topic_pid is always empty...


urbanspacema

Quite a regular
Posted on: 2009/8/20 15:13
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#33

Re: problem with getAllChild

Tnx Trabis for your time, query is ok
(??SELECT `topic_id`,`topic_title` FROM x858_topics WHERE `topic_pid`= 0)

i have changed pid with pid_name

but $pid_name in first while cycle is empty...


urbanspacema

Quite a regular
Posted on: 2009/8/20 14:43
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#34

Re: problem with getAllChild

ok... i made the mods but... seems not work

here is a complete code

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:
 * ****************************************************************************
 */
 
include "../../mainfile.php";

//template assign
$xoopsOption['template_main'] = 'xsitemap_index.html' ;

include_once 
XOOPS_ROOT_PATH."/header.php";
include_once(
XOOPS_ROOT_PATH "/class/tree.php");
include_once 
XOOPS_ROOT_PATH."/modules/xsitemap/class/plugin.php";
include_once 
XOOPS_ROOT_PATH."/modules/xsitemap/include/functions.php";
include_once(
XOOPS_ROOT_PATH "/modules/xsitemap/class/xsitemap_class.php");

$xsitemap_configs $xoopsModuleConfig ;
$pluginHandler =& xoops_getModuleHandler("xsitemap_plugin""xsitemap");

    
$criteria = new CriteriaCompo();
    
$criteria->setSort("plugin_id");
    
$criteria->setOrder("ASC");
    
$numrows $pluginHandler->getCount();
    
$plugin_arr $pluginHandler->getall($criteria);
    
    foreach (
array_keys($plugin_arr) as $i) {    
                if ( 
$plugin_arr[$i]->getVar("topic_pid") == 0)
                {
                    
$module_name $plugin_arr[$i]->getVar("plugin_name");    
                    
$table $plugin_arr[$i]->getVar("plugin_mod_table");    
                    
$id_name $plugin_arr[$i]->getVar("plugin_cat_id");    
                    
$pid $plugin_arr[$i]->getVar("plugin_cat_pid");    
                    
$title $plugin_arr[$i]->getVar("plugin_cat_name");    
                    
$url $plugin_arr[$i]->getVar("plugin_call");    
                    
$order$plugin_arr[$i]->getVar("plugin_weight");    
                    
$online $plugin_arr[$i]->getVar("plugin_online");
                        
                    if( 
$online == ) {
                        
$xsitemap xsitemap_get_map ($table$id_name$pid$title$url$order);            
                    } 
                }
            }        
include_once 
XOOPS_ROOT_PATH."/footer.php";    
?>


functions.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$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`= 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);
    
    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;
    
}

?>


xsitemap_class.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:
 * ****************************************************************************
 */
     
class XoopsDummyObject extends XoopsObject
{
    
/**
     * constructor
     */
    
function XoopsDummyObject($row$id_name 'cid'$pid_name 'pid'$title_name 'title')
    {
        
$this->XoopsObject();
        
$this->initVar($id_nameXOBJ_DTYPE_INT$row[$id_name]);
        
$this->initVar($pid_nameXOBJ_DTYPE_INT$row[$pid_name]);
        
$this->initVar($title_nameXOBJ_DTYPE_TXTBOX$row[$title_name]);
    }
}
?>


urbanspacema

Quite a regular
Posted on: 2009/8/20 13:57
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#35

Re: problem with getAllChild

But xoopstree is deprecated... or not?


urbanspacema

Quite a regular
Posted on: 2009/8/20 13:15
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#36

Re: problem with getAllChild

Here is my code (i'm trying to build a new sitemap module called xsitemap)

<?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$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`= 0" ;
    if (
$order != '')
    {
        
$sql .= " ORDER BY `$order`" ;
    }
    
    
$result $xoopsDB->query($sql);
    
    
$mytree = new XoopsObjectTree($table$id_name$pid);
        
    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);
                echo 
"+++";
                
print_r($child_array);
                echo 
"+++";
            foreach (
$child_array as $child)
            {
                
$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]['url'] = $url.$child[$id_name];
                
                
$j++;
            }
        
//}
        
$i++;
    }
    return 
$xsitemap;
    
}

?>


my problem are in getAllChild. I proviede a numeric id to getAllChild but does not return any value.

the first voice in
$mytree = new XoopsObjectTree($table, $id_name, $pid);
should be an array, but I did not understand where to take this array ...


any advice?
Tnx


urbanspacema

Quite a regular
Posted on: 2009/8/20 12:48
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#37

Re: Need help with a little code

try

<{if $vice_versa == 1}>Something here<{/if}>
instead of
<{if $vice_versa == yes}>Something here<{/if}>


urbanspacema

Quite a regular
Posted on: 2009/8/20 9:32
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#38

Re: The starport at http://the-starport.net

Wow, fantastic design! Many compliments!


urbanspacema

Quite a regular
Posted on: 2009/8/19 18:22
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#39

Re: problem with getAllChild

Ghia
I did not understand, I sent you a pm


urbanspacema

Quite a regular
Posted on: 2009/8/19 17:07
urbanspacema
urbanspacema (Show more)
Quite a regular
Posts: 276
Since: 2004/9/19
#40

problem with getAllChild

Hello
I'm trying to build a module and have some problem to retrive child from parent category.

this is the pice of code

$mytree = new XoopsObjectTree($table$id$pid);
$child_array $mytree->getAllChild($id);


$id is the id of parent category.


Debug:
Warning: array_keys() [function.array-keys]: The first argument should be an array in file /class/tree.php line 79
Warning: Invalid argument supplied for foreach() in file /class/tree.php line 79
Warning: array_keys() [function.array-keys]: The first argument should be an array in file /class/tree.php line 79
Warning: Invalid argument supplied for foreach() in file /class/tree.php line 79



TopTop
« 1 2 3 (4) 5 6 7 ... 19 »