X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   X5 - Creating a new ItemsList type (https://forum.x-cart.com/showthread.php?t=72248)

xgarb 06-08-2015 06:43 AM

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.

tony_sologubov 06-08-2015 12:03 PM

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.

xgarb 06-09-2015 03:12 AM

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.


All times are GMT -8. The time now is 11:27 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.