Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

X5 - Creating a new ItemsList type

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 06-08-2015, 06:43 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default X5 - Creating a new ItemsList type

X-cart comes with three list types for products: Grid, List and Table

How do I get another list type?

In the class I have this

Code:
const DISPLAY_MODE_CLIENT = 'client''; protected function defineWidgetParams() { parent::defineWidgetParams(); $this->widgetParams[self::PARAM_WIDGET_TYPE]->setValue(self::WIDGET_TYPE_CENTER); $this->widgetParams[self::PARAM_DISPLAY_MODE]->setValue(self::DISPLAY_MODE_CLIENT); $this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]->setValue(false); $this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]->setValue(false); }

and I've added the tpl files with the other Itemslist tpl files.

I can see further code in parent classes but I'm not sure what I need to edit.
__________________
Core version: 5.5.xx
Reply With Quote
  #2  
Old 06-08-2015, 12:03 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: X5 - Creating a new ItemsList type

Have a look at the getCenterDisplayModes() method of the \XLite\View\ItemsList\Product\Customer\ACustomer class.

It should give you a clue.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 06-09-2015, 03:12 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: X5 - Creating a new ItemsList type

Thanks, I have it working.

In the class I have....

Code:
const DISPLAY_MODE_CLIENT = 'client';


Code:
/** * Get display modes for center widget type * * @return array */ public static function getCenterDisplayModes() { return array( static::DISPLAY_MODE_GRID => 'Grid', static::DISPLAY_MODE_LIST => 'List', static::DISPLAY_MODE_TABLE => 'Table', static::DISPLAY_MODE_CLIENT => 'Client', ); } /** * Define widget parameters * * @return void */ protected function defineWidgetParams() { parent::defineWidgetParams(); $this->widgetParams[self::PARAM_WIDGET_TYPE]->setValue(self::WIDGET_TYPE_CENTER); $this->widgetParams[self::PARAM_DISPLAY_MODE]->setValue(self::DISPLAY_MODE_CLIENT); $this->widgetParams[self::PARAM_SHOW_DISPLAY_MODE_SELECTOR]->setValue(false); $this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]->setValue(false); }

In my theme I've created in customer/en/items_list/product/center/client/body.tpl

Code:
<list name="itemsList.product.cart" /> <div class="products"> <div class="products-list" IF="getPageData()"> <div FOREACH="getPageData(),product" class="row" style="margin:15px 0"> <div class="col-xs-12 col-sm-4" style="text-align:center"> <widget class="\XLite\View\Image" image="{product.getImage()}" className="photo product-thumbnail" verticalAlign="top" id="product_image_{product.product_id}" alt="{t(#Thumbnail#)}" /> </div> <div class="col-xs-12 col-sm-8"> <div><strong>{product.name:h}</strong></div> <div style="color:grey">{if:product.sku}SKU: {product.sku}{else:}&nbsp;{end:}</div> <div IF="product.getBriefDescription()" class="description product-description">{product.getBriefDescription():h}</div> <widget class="\XLite\View\Price" product="{product}" displayOnlyPrice="false" /> <a href="{buildURL(#product#,##,_ARRAY_(#product_id#^product.product_id,#category_id#^categoryId))}" class="product-link"> View Product Page </a> </div> </div> </div> </div>

For some reason the list name="info" and list name="photo" weren't working like in the other three Itemlists but I prefer to have all the code in one template as above anyway.

I'm using this to make my own template to put related products in a tab and make it nicely responsive. If anyone else does this.. you might not see a change until you have deleted cookies.
__________________
Core version: 5.5.xx
Reply With Quote

The following user thanks xgarb for this useful post:
tony_sologubov (06-15-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:17 AM.

   

 
X-Cart forums © 2001-2020