CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Question on the Tree View In Listbox, thanks.(?)

Print topic Send  topic

Author Message
joejac

Posts: 242
Posted: 11/11/2007, 1:14 PM

Hello,

I would appreciate a lot If somebody can help me with the Tree View In Listbox solution:

(http://forums.yessoftware.com/posts.php?post_id=71501)

I placed the function list_categories() at the end of Common.php, then in the Open event of the page but I always get: page not found. I take out the function and the page is found. Is a page with a record form to create an article.

Please bear in mind that I am not an object oriented programmer. I was only testing if I can get the tree of the categories before I change my code to submit the selected category value.

Thanks a lot
joejac

Here is the code:

1.- in HTML the Label:

<tr class="Controls">
<th>Categorias</th>

<td>{my_tree_menu}</td>
</tr>

2.- this is my full file articulos_events.php

<?php
//BindEvents Method @1-AA8F8EEC
function BindEvents()
{
global $articulos;
$articulos->my_tree_menu->CCSEvents["BeforeShow"] = "articulos_my_tree_menu_BeforeShow";
}
//End BindEvents Method

//articulos_my_tree_menu_BeforeShow @31-9311207E
function articulos_my_tree_menu_BeforeShow(& $sender)
{
$articulos_my_tree_menu_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $articulos; //Compatibility
//End articulos_my_tree_menu_BeforeShow

//Custom Code @32-2A29BDB7
// -------------------------

//-- BEGIN Menu tree for articulos.php

function list_categories() {

$names=array();
$cats=array();
global $dyn_menu;
$dyn_menu = "";
$db = new clsDBConnection1();
//- $db = new clsDBcms();
$dyn_menu .="<select name=\"category\">";
// adjust the query below with the proper field names and table name
// DON'T change the 'id', 'name' and 'parent' aliases in the query!
$SQL = "SELECT categoria_no AS id, categoria_nombre AS name, parent_categoria_no AS parent FROM categorias";
$result = $db->query($SQL);

//while ($row = mysql_fetch_assoc($result))

while ($db->next_record())
{
//$names[$row['id']] = $row['name'];
//$cats[$row['id']] = $row['parent'];
$names[$db->f("id")] = $db->f("name");
$cats[$db->f("id")] = $db->f("parent");
}

display_options(hierarchize($cats, 0), $names);
$db->close();
$dyn_menu .="</select>";
return $dyn_menu;
}

function hierarchize(&$cats, $parent) {

$subs = array_keys($cats, $parent);
$tree = array();
foreach ($subs as $sub) {
$tree[$sub] = hierarchize($cats, $sub);
}
return count($tree) ? $tree : $parent;
}

function display_options(&$tree, &$names, $nest = 0) {
global $dyn_menu;
foreach ($tree as $key => $branch) {
$indent = $nest ? str_repeat('--', $nest) . '| ' : '';

$dyn_menu .="<option value=\"$key\">$indent{$names[$key]}</option>\n";

if (is_array($branch)) {
display_options($branch, $names, $nest + 1);
}
}
}

//-- END Menu tree for articulos.php

$articulos->my_tree_menu ->SetValue(list_categories() );
// -------------------------
//End Custom Code

//Close articulos_my_tree_menu_BeforeShow @31-52ED58BF
return $articulos_my_tree_menu_BeforeShow;
}
//End Close articulos_my_tree_menu_BeforeShow


?>
View profile  Send private message
feha


Posts: 712
Posted: 11/11/2007, 1:20 PM

Hi
that is very old solution i wish i could help you ...

i can't find latest updated version in my archive (i'm very busy to search on all my backups)

please try to contact "headhunter" (forum user) he can help you.


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.