Mark Round Posted July 4, 2020 Posted July 4, 2020 I’ve tried passing the purchases template from nexus in a block but with no luck . I want to display purchases displayed in the my purchases page Which is shown on the url My site.com/clients im guessing it’s because the page controller is missing (cms rather than nexus) and the $purchases variable is not passed . Is there an easier way of doing this ?
Solution bfarber Posted July 6, 2020 Solution Posted July 6, 2020 This is how we list purchases on that page, which you could emulate in a custom block $where = array( array( 'ps_member=?', \IPS\Member::loggedIn()->member_id ) ); $parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts(); if ( \count( $parentContacts ) ) { $or = array(); foreach ( $parentContacts as $contact ) { $where[0][0] .= ' OR ' . \IPS\Db::i()->in( 'ps_id', $contact->purchaseIds() ); } } $where[] = array( 'ps_show=1' ); /* Get only the purchases from active applications */ $where[] = array( "ps_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')" ); $purchases = array(); foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', $where, 'ps_active DESC, ps_expire DESC, ps_start DESC' ), 'IPS\nexus\Purchase' ) as $purchase ) { $purchases[ $purchase->parent ][ $purchase->id ] = $purchase; } \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->purchases( $purchases ); Mark Round and BomAle 1 1
Mark Round Posted July 8, 2020 Author Posted July 8, 2020 Can I not simply call the template and output from that?
bfarber Posted July 9, 2020 Posted July 9, 2020 You have to pass the data to the template to display.
Mark Round Posted July 9, 2020 Author Posted July 9, 2020 ok thanks again,i tired adding in some of the code you stated above but it wont display anything.Sorry for asking so many questions
Recommended Posts