Quick search:

Navigation with relations table?

pheller
2005-06-15 18:08:26
 
Hi,

  First I should say that I am enjoying phpPeanuts -- it's an excellent tool.  However, I am unfortunately not an expert with either php or databases, and I still have trouble wrapping my head around stuff that is really object oriented.

With that being said, here is what I'm trying to accomplish:

Consider three tables: People, Locations, and Locations_People_Relations

All three have an ID column, and the idea is that some locations are shared by many people, and to reduce the amount of data duplication, and maintain data consistency, I'd rather enter the location once in Locations, and associate it with many people in the relations table.

Also, people can have many locations, hence the need for a many-many relationship table.

Lastly, I'd basically like to do this with a addMultiValueProp call, but I want to display it within a scrollable div layer on the "people" page.

Any ideas how this might be doable?

I appreciate any help you might be able to offer...!

Regards,

  --phil
henk
2005-06-17 00:02:18
 
Hi Phil.

As you may have read in my previous post on this forum, i have recently been working on components for user interfacing M to N relations more elegantly.

I guess you want to display it in a scrollable div on the People EditDetailsPage. As you may expect, this begins with the creation of a class PeopleEditDetailsPage in the application classFolder, extending ObjectEditDetailsPage.

I suggest you use a TabsPart to not only create the DIV, but also to allow the user to select it or select the other DIV, that will be holding the normal content of the EditDetailsPage (the DetailsPart). Creating the TabsPart can be done by adding a printMainPart function to the PeopleEditDetailsPage class:

    function printMainPart() {
        $this->printPart('DetailsFormStartPart');
        $this->printPart('TabsPart', array(
                'Details' =>'Details'
                , 'Locations' => array('Locations', 'MtoNPropertyPart', 'locations')
            ),
        'Details'
        );
        print "
            </form>";
        $this->printScaleContentScripts();
    }

The TabsPart is a quite simple part that calls upon subparts to fill in the contents of each tabs' scrollable DIV. The real work is done by the  MtoNPropertyPart inside the Locations tab's scrollable DIV. It produces a table with locations on the left side taht holds the locations that are already related to the People object. On the right side there is an Iframe that shows an NtoMSearchPage that allows you to search for locations. When you click on a row in the table of the NtoMSearchPage a row for the corresponding Location is added to the lefthand table. When you click on a 'remove' icon of a row in the lefthand table, that  row is removed. All changes to the lefthand table happen client-side. When you click the "Save" button the changes are submitted to the server, processed by PntObjectSaveAction, which of course calls upon the instance of People to make the actual change to the value of its 'locations' property.

The problem is: you do not have the MtoNPropertyPart, because it has not yet been released. As yet it only exists as a part of our (MetaClass') own closed source class library and has not yet been refactored to the open source pnt library. Because normal commercial work has priority over unpaid phpPeanuts development and becuase i also like to enjoy the good wheather (the wheather in Holland is not very nice except in the summer), it may take a while before i get to do that and finish release the phpPeanuts 1.2 beta it will be in. It's alltogether quite complicated code, too complicated to explain here how to make the MtoNPropertyPart and NtoMSearchPage yourself. So i am afraid that you will have to wait for the beta release.

Now i could explain to you how to factor out the skinDetailsFormStartPart from the skinDetailsFormPart, and how to implement the printScaleContentScripts function, and how to make a PropertyPart that is much like the normal PropertyPage. But i am afraid that that will not be much better then the PropertyPage you already get if you make a multi value property 'locations' on the People class and write a getLocations method that returns the related Location. So i am afraid the best i can do is send you an email as soon as 1.2 beta is available.

There are two ways you can speed up the release of 1.2 beta:
1. Find me a sponsor that is willing to pay enough to give the phpPeanuts development priority over enjoying the good weather,
2. Pray for bad wheather in the Netherlands.
It may not surprise you that personally i prefer the first option ;-)

Greetings,

Henk Verhoeven.
pheller
2005-06-17 00:15:52
 
I'd love to sponsor phpPeanuts development, but alas, my project is
also operating on a shoestring budget ;-)

Thanks for the response.  I will anxiously await 1.2 beta, and
hopefully an example to more easily wrap my head around the conceptual
implementation.

Thanks again and enjoy the weather!

Regards,

--phil

Add a Reply
Loading form, please wait
The website will not send you an e-mail when a reply is added to this topic

Back to Topics List