473,809 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing a Category Hierarchy where to research?

I'm looking into writing a Category Hierarchy on a site I've written
and am looking for some information about writing this kind of code.
Maybe some samples or a book. Any information would be helpful.

Thanks,

Troy Lynch
Jul 17 '05 #1
2 2288
Troy Lynch wrote:
I'm looking into writing a Category Hierarchy on a site I've written
and am looking for some information about writing this kind of code.
Maybe some samples or a book. Any information would be helpful.

Thanks,

Troy Lynch


Hi Troy,

Mabe you are looking for something like this?

<?php
// Copyright (c) the partners of MetaClass, 2003, 2004
// Licensed under the Academic Free License version 2.0

includeClass('P ntDbObject', 'pnt/db');

class TreeItem extends PntDbObject {

var $parentId = 0;

function initPropertyDes criptors() {
parent::initPro pertyDescriptor s();

$this->addFieldProp(' parentId', 'number', false, null, null, 1, '6,0');
$this->addDerivedProp ('parent', 'TreeItem', false);
$prop =& $this->addMultiValueP rop('children', 'TreeItem');
$prop->setTwinName('p arent');

$this->addFieldProp(' name', 'string', false, null, null, 0, '40');
}

/** @static
* @return String the name of the database table the instances are
stored in
* @abstract - override for each subclass
*/
function getTableName()
{
return 'ex_tree';
}

/** Returns the directory of the class file
* @static
* @return String
*/
function getClassDir()
{
return 'exampleA1';
}

function getLabel()
{
return $this->name;
}

}
?>

To try it out go:

http://www.phppeanuts.org/examples/e...tType=TreeItem

In the user interface it may not look like a tree, but that is a matter
of web page design. To make objects of some other peanuts class in the
same application classFolder reference to a tree item, all you have to
do is add the following to its initPropertyDes criptors() method:

$this->addFieldProp(' categoryId', 'number', false, null, null, 1, '6,0');
$this->addDerivedProp ('category', 'TreeItem', false);

and add a categoryId column to its database table. Assuming you did not
override the default edit details page and uiFieldProperti es for the
class, this will automaticly enable the selection of a category from a
list or, if there are many categories, from a search dialog. If you
write your own dialog class and name it TreeItemDialog you can make a
nice visual representation of the category tree to select from and it
will be used automaticly by the default edit details page.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

BTW, the example is not in the download. It requires a few more files,
very similar to example 1. Anyone interested please send me an email if
you want to receive the complete exampleA1 by email.

Jul 17 '05 #2
Troy Lynch wrote:
I'm looking into writing a Category Hierarchy on a site I've written
and am looking for some information about writing this kind of code.
Maybe some samples or a book. Any information would be helpful.

Thanks,

Troy Lynch


I just added a simple graphical representation, see
http://www.phppeanuts.org/examples/exampleA1/

its code:

printBranches( getRoots() );

function printBranches(& $treeItems, $depth=0)
{
while (list($key) = each($treeItems ) ) {
for ($i=0; $i<$depth; $i++)
print "&nbsp;&nbsp;&n bsp;";
$item =& $treeItems[$key];
?><A HREF='index.php ?pntType=TreeIt em&id=<?php print $item->get('id') ?>'
title='edit details'><?php print $item->get('name') ?></A><BR>
<?php
printBranches($ item->get('children' ), $depth + 1);
}
}

Groeten,

Henk Verhoeven,
www.phpPeanuts.org.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3386
by: Travis Pupkin | last post by:
Hey, I've done a number of product catalogs/galleries with one or two category levels (Category > Subcategory). The straightforward way to do this, of course, is to use database fields for Category and Subcategory and query off of those fields. I have a client now who is interested in what sounds to me to be an unnecessarily complex catalog with an as of yet undefined number of category levels at their disposal.
11
4060
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it again, Excel hangs. OR if I open Excel again (say from a desktop icon) before I close Access, Excel hangs. (this has happened for both 97 & 2000 for me) I of course thought that I mustn't be unloading a variable properly.
5
2284
by: Red | last post by:
Hi, Can someone give me some pointers on how to approach creating multi level category navigation for a website? Take ebay for example. No matter where you are, you have a navigation bar telling you how you got there, and can click on these to go to any of the parent levels; Music > CDs > Folk > American
3
2523
by: Rich Shepard | last post by:
I need to learn how to process a byte stream from a form reader where each pair of bytes has meaning according to lookup dictionaries, then use the values to build an array of rows inserted into a sqlite3 database table. Here's the context: The OMR card reader sends a stream of 69 bytes over the serial line; the last byte is a carriage return ('\r') indicating the end of record. Three pairs (in specific positions at the beginning of the...
1
2192
by: =?Utf-8?B?TWljaGFlbCBCbHVtZW50aGFsLCBNQ1NFLCBNQ0FE | last post by:
I am writing a .NET 1.1 C# windows service that writes to a dedicated event log (not the application event log, but one that I created). I want to make full use of all the fields in an event log record - category, event ID, etc. I would like to make use of a message file as well. I have created a message file DLL per the instructions at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wes/wes/sample_message_text_file.asp...
3
5968
by: KDawg44 | last post by:
Hi, I am trying to write a page that creates some barcodes using the PEAR Image_Barcode module. I am getting one barcode to write just fine but it will not print out any more than one and will not print any text on the page. What I would like is to pass in the information to be barcoded, and a category for each barcode, then have a page displayed that groups the barcodes by category.
4
1052
by: Andy | last post by:
Hi guys, I'm writing a piece of software for some Thai friend. At the end it is supposed to print on paper some report with tables of text and numbers. When I test it in English, the columns are aligned nicely, but when he tests it with Thai data, the columns are all crooked. The problem here is that in the Thai writing system some times two or more characters together might take one single space, for example งิ...
3
3378
by: JJ297 | last post by:
Hello I'm a newbie to programming and need help writing an if statement. I have a database set up in SQL with the following fields: Category Questions Answers I only want one category to appear for all of the questions and answers submitted for that category. The way I have it set up now all if a question is submitted for the same category then the category
1
3536
by: TomLasky | last post by:
Hi everyone, I'm creating a very powerful web store script in ASP. One of the things I am adding is to allow the user to create their own categories and sub categories for items they wish to sell. This isn't a new concept or anything but what I'm doing is allowing them to create "Main or Master Categories". An example of a main category would be "Electronics". They can now create sub categories under "Electronics". If for example...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.