PHP Classes

How to show a three level tree of this Binary Plan

Recommend this page to a friend!

      PHP MLM Tree Binary Plan  >  All threads  >  How to show a three level tree of...  >  (Un) Subscribe thread alerts  
Subject:How to show a three level tree of...
Summary:How to show a three level tree of this Binary Plan
Messages:5
Author:WAAAUH
Date:2018-03-02 22:10:07
 

  1. How to show a three level tree of...   Reply   Report abuse  
Picture of WAAAUH WAAAUH - 2018-03-02 22:10:07
Thanks for your package! I tested it and it good works but I tried show three level tree of Binary Paln and can not did it. How to show three level of it?

  2. Re: How to show a three level tree of...   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2018-03-03 12:31:16 - In reply to message 1 from WAAAUH
The example provided is a basic management screen. It displays the immediate left and right legs for any selected rep and a breadcrumb working its way up the sponsors to the primary rep for that tree.

If you are asking how to add the next level to the management screen... it can be done, however it adds complexity to the management that can be confusing. I will explain how to display 3 levels and you can deal with the complex forms to manage that many levels from one screen.

If you are only asking how to display the levels, then here is how to get that data.

With three levels we need information on...

Current Rep
Sub L - Sub R
Sub L L - Sub L R - Sub R L - Sub R R

We would use the rRep method to get the data we needed, assuming we instantiated the class as $mbinary and are using the record ID to retrieve the data...

$curRep = $mbinary->rRep($curID);

The $curID will come from key value pair we choose to make available as a request. For example, if it is in the URL as ?id=4, then $curID = $_REQUEST['id'], which in this case will be 4.

The $curRep will be a json object containing the current rep and immediate left and right reps sponsored. What we will call Sub L and Sub R.

We would use this to get the next level down from the Subs...

if( !empty($curRep->reps) ){

if( $currentRep->reps[0]->leg ){

$subL = ( empty($curRep->reps[1]) ) ? null : $curRep->reps[1];
$subR = $curRep->reps[0];

}else{

$subL = $curRep->reps[0];
$subR = ( empty($curRep->reps[1]) ) ? null : $curRep->reps[1];

}

}

The logic above just tests that there are reps and places them on the proper leg. Now we can get the reps for each of those legs...

$dataL = $mbinary->rRep($subL->recordID);
$dataR = $mbinary->rRep($subR->recordID);

You would use the same logic above applied to the $dataL and then again to the $dataR object to assign the $subLL, $subLR, $subRL and $subRR. When it is all done, you will have an object for the current rep and 2 levels down as...

$curRep
$subL - $subR
$subLL - $subLR - $subRL - $subRR


  3. Re: How to show a three level tree of...   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2018-03-03 12:37:42 - In reply to message 2 from Dave Smith
Of course I had a typo in that post...

if( $currentRep->reps[0]->leg ){

should be

if( $curRep->reps[0]->leg ){

  4. Re: How to show a three level tree of...   Reply   Report abuse  
Picture of WAAAUH WAAAUH - 2018-03-03 13:32:27 - In reply to message 3 from Dave Smith
Thank you very much!

  5. Re: How to show a three level tree of...   Reply   Report abuse  
Picture of Tosin Omojola Tosin Omojola - 2019-09-24 13:35:00 - In reply to message 3 from Dave Smith
Thank you so much. The script is very helpful