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

Adding a field to the banner slide

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-07-2016, 01:17 PM
 
AlexB AlexB is offline
 

Newbie
  
Join Date: Apr 2016
Posts: 3
 

Default Adding a field to the banner slide

I'm trying to add live text to the banner slide. I have followed the tutorial here:

http://kb.x-cart.com/display/XDD/Adding+new+property+to+a+product

I've added two fields to the model:

PHP Code:
<?php
// vim: set ts=4 sw=4 sts=4 et:
namespace XLite\Module\My\Module\Model;

class 
BannerRotationSlide extends \XLite\Model\BannerRotationSlide implements \XLite\Base\IDecorator
{
    
/**
     * @Column (type="string", length=1024)
     */
    
protected $title;

    
/**
     * @Column (type="string", length=1024)
     */
    
protected $subtitle;
}

So far, I created the new model, and it's updated the database correctly when I redeploy the store.

But I can't seem to get the new fields to show up in the admin area. This is my view file:

//BannerRotationSlide.php
PHP Code:
<?php
// vim: set ts=4 sw=4 sts=4 et:


namespace XLite\Module\My\Module\View\Model;


class 
BannerRotationSlide extends \XLite\View\Model\BannerRotationSlide implements \XLite\Base\IDecorator
{
    public function 
__construct(array $params = array(), array $sections = array())
    {
        
parent::__construct($params$sections);

        
$this->schemaDefault += array (
            
'title' => array(
                
self::SCHEMA_CLASS    => 'XLite\View\FormField\Input\Text',
                
self::SCHEMA_LABEL    => 'Title',
                
self::SCHEMA_REQUIRED => false,
            ),
            
'subtitle' => array(
                
self::SCHEMA_CLASS    => 'XLite\View\FormField\Input\Text',
                
self::SCHEMA_LABEL    => 'Subtitle',
                
self::SCHEMA_REQUIRED => false,
            ),
        );
    }
}

So, first question is am I editing the correct file, BannerRotationSlide.php? If so, what am I doing wrong here?
__________________
5.2
Reply With Quote
  #2  
Old 04-08-2016, 11:11 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Adding a field to the banner slide

I have not read through your code, or looked at the files to see what the correct code is. But one thing to always check is the run directory.

Are your module directories showing up in the run directory after rebuild? Is your file showing up? Is it extending/modifying the class correctly? If not then you may have namespace or filename issues, module might not be enabled, etc.

It may not be your code, you need to ensure that the basics are working first.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 04-08-2016, 12:08 PM
 
AlexB AlexB is offline
 

Newbie
  
Join Date: Apr 2016
Posts: 3
 

Default Re: Adding a field to the banner slide

Ah, yes, the BannerRotationSlide.php file is there, but the BannerRotation.php file extending the view model is not. I will double check, but my classes look the same as the example code (with the relevant bits changed). Any ideas why that isn't getting copied over?
__________________
5.2
Reply With Quote
  #4  
Old 04-08-2016, 01:23 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Adding a field to the banner slide

You call both classes

class BannerRotationSlide

That's your error
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 04-10-2016, 08:59 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Adding a field to the banner slide

There is no \XLite\View\Model\BannerRotationSlide class. "View\Model\*" classes are for pages where you edit a single object. In case of banner slides there is no such a page and all slides are managed on a single page.

I believe you should look into decorating this class:
\XLite\View\ItemsList\BannerRotationImages
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #6  
Old 04-11-2016, 07:16 AM
 
AlexB AlexB is offline
 

Newbie
  
Join Date: Apr 2016
Posts: 3
 

Default Re: Adding a field to the banner slide

None of this is working so far. To clarify, I can see the columns in the database, so decorating /Model/BannerRotationSlide.php works to create the database. It also allows me to add the following in my banner rotation body.tpl and show the results:

PHP Code:
{* vimset ts=2 sw=2 sts=2 et: *}

{**
 * 
Banner rotation widget template
 
*
 * @
author    Qualiteam software Ltd <info@x-cart.com>
 * @
copyright Copyright (c2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
 
* @license   http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
 
* @link      http://www.x-cart.com/
 
*}

<
div id="banner-rotation-widget" class="carousel carousel-fade banner-carousel">
  {
displayCommentedData(getCommentedData())}

  <!-- 
Indicators -->
  <
ol class="carousel-indicators" IF="{isRotationEnabled()}">
    {foreach:
getImages(),i,image}
      <
li data-target="#banner-rotation-widget" data-slide-to="{i}"></li>
    {
end:}
  </
ol>

  <
div class="carousel-inner" role="listbox">
    {foreach:
getImages(),image}

      <
a href="{image.bannerRotationSlide.getLink()}" class="item">
          <
h1>{image.bannerRotationSlide.getTitle()}</h1>
          <
h2>{image.bannerRotationSlide.getSubtitle()}</h2>
        <
img src="{image.getFrontURL()}" alt="{image.getAlt()}" >
      </
a>
    {
end:}
  </
div>
</
div

What I can't seem to get working is to have those two extra fields show up in the admin area in Catalog/FrontPage/BannerRotation
__________________
5.2
Reply With Quote
  #7  
Old 04-11-2016, 10:45 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Adding a field to the banner slide

By decorating the \XLite\Model\BannerRotationSlide you add the custom columns to the database table. This also lets you read data from these columns in your templates.

You also tried to decorate \XLite\View\Model\BannerRotationSlide. As I said there is no such a class, that's why you code doesn't work - you modify something that doesn't exist. There would be such a class if X-Cart had a page for editing a single banner. But there is no such a page and all banners are managed on a single page.

I suggest you to look into decorating this class: \XLite\View\ItemsList\BannerRotationImages. I'm not sure 100%, but I believe that this is the class that controls what fields should be shown in the table of banner slides when you edit them.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
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 05:44 PM.

   

 
X-Cart forums © 2001-2020