Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Developers Corner ::  Module Development ::  Nested pnRender items and caching...

Moderated by: Support Team

Bottom
Nested pnRender items and caching...

  • Link to this postingPosted: 25.04.2006, 10:50
    Profile Homepage
    uheweb
    rank:
    Professional Professional
    registered:
     September 2004
    Status:
    offline
    last visit:
    07.08.08
    Posts:
    813
    The following generates a nested view of data. Parent is items, child is propitems.

    The API function basically grabs all items, then as it iterates the parents, it has a secondary loop that iterates related children within the parent loop:



    Code
    $items = pnModAPIFunc('RentalReport',
                              'user',
                              'get');
        $propitems = pnModAPIFunc('RentalReport',
                              'user',
                              'getpropbycomm');
       
        if (!$items) {
            return pnVarPrepHTMLDisplay(_EXAMPLEITEMFAILED);
        }

        // Create output object
        $pnRender =& new pnRender('RentalReport');

     
       
        $RentalReportpropitems = array();
        $RentalReportitems = array();

        foreach ($items as $item) {                    // Parent loop
                $pnRender->assign($item);   
               
            foreach ($propitems as $propitem) {      // Child loop
               
                if ($propitem['cid'] == $item['id']) {
                    $pnRender->caching=false;
                    $pnRender->assign($propitem);
                    $RentalReportpropitems[] = $pnRender->fetch('RentalReport_user_proprow_read.htm', $propitem['id']);
                }  //End related Child
            }
               
               
                $pnRender->assign('propitems', $RentalReportpropitems);
                    $RentalReportitems[] = $pnRender->fetch('RentalReport_user_row_read.htm', $item['id']);
                $RentalReportpropitems = ''; $RentalReportpropitems = array();
            } // End parent
           


        $pnRender->caching=false;

        $pnRender->assign('items', $RentalReportitems);
       
        return $pnRender->fetch('RentalReport_user_view.htm');
    }


    Without the FALSE for the caching in the child loop, with pnRender caching turned on, then the first child record is the only one that shows...for ALL results! IN other words, every parent renders correctly, but whatever children they have do not show - the FIRST child shows in their place, over and over for every parent.

    What is the right way to do this with caching? The data will not change often, so even a full cache of all parent and child items would be great.

    Thanks for any insight.

    UHEweb

Start ::  Developers Corner ::  Module Development ::  Nested pnRender items and caching...

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to Zikula