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

Decorate XC module

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-23-2018, 04:08 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Decorate XC module

I am trying to decorate an existing XC module (Froala Editor) from my own module:

PHP Code:
<?php

namespace XLite\Module\Udg\Tweaks\View\FormField\Textarea;

/**
 * @Decorator\After (“XC\FroalaEditor”)
 */
class Advanced extends \XLite\Module\XC\FroalaEditor\View\FormField\Textarea\Advanced implements \XLite\Base\IDecorator
{
  
// Override functions here...
}

I keep getting the same error:

Fatal error: Class 'XLite\Module\XC\FroalaEditor\View\FormField\Texta rea\AdvancedAbstract' not found in /app/classes/XLite/Module/Udg/Tweaks/View/FormField/Textarea/Advanced.php on line 8

I have tried also using @Decorator\Depend (“XC\FroalaEditor”)

Any idea what I am doing wrong?
__________________
5.3.5.8
Reply With Quote
  #2  
Old 05-23-2018, 05:36 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Decorate XC module

Here is how the \XLite\Module\XC\FroalaEditor\View\FormField\Texta rea\Advanced class is declared:
PHP Code:
namespace XLite\Module\XC\FroalaEditor\View\FormField\Textarea;

/**
 * Froala textarea widget
 *
 * https://github.com/xcart/wysiwyg-editor
 */
class Advanced extends \XLite\View\FormField\Textarea\Advanced implements \XLite\Base\IDecorator
{
    
// ...


The important point there is that this class implements the \XLite\Base\IDecorator interface.

This means that it is not a new class, but a hack into an existing class (\XLite\View\FormField\Textarea\Advanced).

That's why in your module you should extend your class from \XLite\View\FormField\Textarea\Advanced, not from \XLite\Module\XC\FroalaEditor\View\FormField\Texta rea\Advanced
__________________
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
  #3  
Old 05-23-2018, 06:25 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Re: Decorate XC module

Thanks for this. That's what I thought too and I tried it as well. Error message is gone but nothing seems to happen.

What I want basically is to alter the buttons in the editor (which ones are showing). But maybe this is not the place to do it?

PHP Code:
<?php

namespace XLite\Module\Udg\Tweaks\View\FormField\Textarea;

/**
 * @Decorator\After(“XC\FroalaEditor”)
 */
class Advanced extends \XLite\View\FormField\Textarea\Advanced implements \XLite\Base\IDecorator
{
  
/**
   * Return list of froala toolbar buttons
   *
   * @return array
   */
  
protected function getFroalaToolbarButtons()
  {

    return [
      
'fontSize',
      
'|''bold''italic''underline''strikeThrough''color''clearFormatting''print',
      
'|''paragraphFormat''paragraphStyle''formatOL''formatUL',
      
'-''align''indent''outdent''insertHR''quote',
      
'|''insertImage''insertTable''insertLink''insertVideo',
      
'|''undo''redo''html''fullscreen''help''shortcutsHint'
    
];
  }
}

Here I just removed the first button (fontFamily) but I still see it in all instances of the editor.
__________________
5.3.5.8
Reply With Quote
  #4  
Old 06-08-2018, 11:57 AM
 
CDWPChris CDWPChris is offline
 

Member
  
Join Date: Apr 2018
Posts: 16
 

Default Re: Decorate XC module

This might be a dumb question but... Have you Re-deployed the store?
__________________
X Cart 5.4.1.28
Crisp White Skin
Reply With Quote
  #5  
Old 06-13-2018, 01:12 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Re: Decorate XC module

Of course I have redeployed the store. This has an effect on some very few implementations of the editor. Like on certain pages, I see my changes and on others it's the default buttons set. That means this is used, sometimes, but not always. Great. Now could we possibly get an answer from XC team about HOW WE ARE SUPPOSED TO REMOVE A BUTTON FROM THE EDITOR THAT YOU USED ACROSS YOUR ENTIRE PRODUCT?? Thank you SO MUCH in advance.
__________________
5.3.5.8
Reply With Quote
  #6  
Old 06-25-2018, 04:07 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Re: Decorate XC module

One month later, is there anyone willing to provide a bit of help on that?
__________________
5.3.5.8
Reply With Quote
  #7  
Old 06-25-2018, 04:50 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,189
 

Default Re: Decorate XC module

See \XLite\View\FormField\Textarea\Advanced under /var/run/classes

It will have the class it's extending/coming from.
It is possible some other module comes after yours and overrides your changes
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #8  
Old 06-25-2018, 05:42 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Re: Decorate XC module

Nope. It's my module. Yet it doesn't affect all instances of the editor, as I described already.
__________________
5.3.5.8
Reply With Quote
  #9  
Old 06-25-2018, 07:15 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

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

Default Re: Decorate XC module

Quote:
Originally Posted by amarquis
Of course I have redeployed the store. This has an effect on some very few implementations of the editor. Like on certain pages, I see my changes and on others it's the default buttons set. That means this is used, sometimes, but not always. Great. Now could we possibly get an answer from XC team about HOW WE ARE SUPPOSED TO REMOVE A BUTTON FROM THE EDITOR THAT YOU USED ACROSS YOUR ENTIRE PRODUCT?? Thank you SO MUCH in advance.

What pages do you still see the old version of the editor on?

Tony
__________________
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
  #10  
Old 06-25-2018, 07:41 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Re: Decorate XC module

For example: admin.php?target=global_tabs -> Then click on "New tab".

Here there are 2 fields with the WYSIWYG editor: "Content" and "Brief info"
"Content" field works with my changes (removed some buttons)
"Brief info" doesn't

- The "Add product" form, it doesn't work
- The "Edit category" form, it works
- For Vendors, My Account -> Company details -> Description, it works but I am quite surprised as I am pretty sure it did not work a few days/weeks ago.

Thx
__________________
5.3.5.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:35 AM.

   

 
X-Cart forums © 2001-2020