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)
-   -   Decorate XC module (https://forum.x-cart.com/showthread.php?t=76267)

amarquis 05-23-2018 04:08 AM

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?

qualiteam 05-23-2018 05:36 AM

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

amarquis 05-23-2018 06:25 AM

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.

CDWPChris 06-08-2018 11:57 AM

Re: Decorate XC module
 
This might be a dumb question but... Have you Re-deployed the store?

amarquis 06-13-2018 01:12 AM

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.

amarquis 06-25-2018 04:07 AM

Re: Decorate XC module
 
One month later, is there anyone willing to provide a bit of help on that?

cflsystems 06-25-2018 04:50 AM

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

amarquis 06-25-2018 05:42 AM

Re: Decorate XC module
 
Nope. It's my module. Yet it doesn't affect all instances of the editor, as I described already.

tony_sologubov 06-25-2018 07:15 AM

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

amarquis 06-25-2018 07:41 AM

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


All times are GMT -8. The time now is 12:37 AM.

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