Adding a Subpart
Posted: 15 Nov 2015, 03:36
I'm wanting to display subcategories as part of the catalog list. Reading through another post, it seems like the best way to do it is to add a subpart, so this is what I did:
In my Laravel project, I created a directory structure as such:
In the first directory, I put Default.php with all the skeleton code and the following class declaration and _setViewParams (as per the other post I read):
In the layouts directory tree, I put subcategories-header-default.html and subcategories-body-default.html
In the shop.php file, I put this configuration:
Cleared the cache and reloaded the page but I don't see anything. I'm guessing it's not working due to my inexperience with Laravel but I'm not sure what I'm doing wrong...
In my Laravel project, I created a directory structure as such:
Code: Select all
<root>/ext/subcategories/client/html/src/Client/Html/Catalog/List/Subcategories
<root>/ext/subcategories/client/html/layouts/catalog/list
Code: Select all
class Client_Html_Catalog_List_Subcategories_Default
extends Client_Html_Abstract
implements Client_Html_Common_Client_Factory_Interface
{
Code: Select all
protected function _setViewParams( MW_View_Interface $view, array &$tags = array(), &$expire = null ) {
if ( !isset( $this->_cache ) ) {
$this->addMetaItem( $itemOrItemList, 'catalog', $this->_expire, $this->_tags );
$this->_addMetaList( $prodid, 'catalog', $this->_expire );
$controller = Controller_Frontend_Factory::createController( $this->_getContext(), 'catalog' );
$view->subcategoriesList = $controller->getCatalogTree( $view->param( 'f_catid' ), array( 'text', 'media' ), MW_Tree_Manager_Abstract::LEVEL_LIST );
$this->_cache = $view;
}
$expire = $this->_expires( $this->_expire, $expire );
$tags = array_merge( $tags, $this->_tags );
return $this->_cache;
}
In the shop.php file, I put this configuration:
Code: Select all
'catalog' => array(
'list' => array(
'subparts' => [''head', 'quote', 'promo', 'subcategories', 'pagination', 'items', 'pagination' ],
),
),