1
Catzwolf
How to use Spaw within your modules. Examples
  • 2004/1/3 17:04

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Replacing the textboxarea in XOOPS is easier than you might believe and this little tutorial should help guide you in this.

There are two methods depending on whether the module uses XoopsFormClass or not.

The first example is replacing the XOOPS original Textboxarea (A module that does NOT use XoopsFormClass)

The first thing you need to do is setup the module to use the Spaw editor, without this you will not be able to use spaw and could save you countless hours trying to figure out why spaw is not working

Open up the file /modules/news/admin/storyform.inc.php and at roughly line 31 look for this:

Quote:

include XOOPS_ROOT_PATH."/include/xoopscodes.php";


And insert these lines underneath the above line:

Quote:

$spaw_root = XOOPS_ROOT_PATH . '/modules/spaw/';
include_once $spaw_root . 'spaw_control.class.php';


NB: These lines need to be executed as quickly as possible within the page, so try and get them as near to the top of the page as possible. But MUST be after any includes such as mainfile.php, admin_header.php, or cp_header.php. General rule would be to add after any 'includes' already there.

Next we need to replace the TextBoxArea it self, Look for the following at roughly line 88

Quote:

xoopsCodeTarea("bodytext", 60, 15, 2);
xoopsSmilies("bodytext");


And replace it with these lines:

Quote:

$sw = new SPAW_Wysiwyg( 'bodytext', $bodytext, 'en', 'full', 'default', '99%', '600px' );
$sw -> show();


You will notice that the first item in the function xoopsCodeTarea is 'bodytext', you will have to use the same item in the spaw function, but you will also have to include the item taken from the database. In this case $bodytext

Another example here is when using the spaw editor in a module that uses XoopsFormClass.

To replace a TextBoxArea with XoopsFormClass, you will have to look for these XoopsFormDhtmlTextArea or XoopsFormTextArea.

Lets just say that the news module had been updated to use XoopsForm class, the line you would be searching for to replace could look something like this:

Quote:

$sform -> addElement( new XoopsFormDhtmlTextArea( _AM_EXTEXT, 'bodytext', $bodytext, 15, 60 ), true );


You would have to replace this with:

Quote:

ob_start();
$sw = new SPAW_Wysiwyg( 'bodytext', $bodytext, 'en', 'full', 'default', '99%', '600px' );
$sw -> show();
$sform -> addElement( new XoopsFormLabel( _AM_EXTEXT, ob_get_contents() ) );
ob_end_clean();


Always use this when replacing a TextBoxArea in XoopsFormClass.

Hope this helps you

2
CBlue
Re: How to use Spaw within your modules. Examples

Thanks for this tutorial, Catzwolf!

3
Catzwolf
Re: How to use Spaw within your modules. Examples
  • 2004/1/3 17:32

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Np

4
svaha
Re: How to use Spaw within your modules. Examples
  • 2004/1/3 19:26

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


Thanks Catzwolf, but I must be dumb/dumber/dumbest or something because I still don't get it.
This is what I changed in WF-section :

Ok so I changed wfsarticle.php to :
Around line 17 :
Quote:
//hhts include spaw
$spaw_root = XOOPS_ROOT_PATH . '/modules/spaw/';
include_once $spaw_root . 'spaw_control.class.php';


And around line 1038 :
Quote:
//hhts inbouw Spaw.
//echo "

"._AM_INTROTEXT."

\n";
//xoopsCodeTarea("maintext", 60, 15);
$sw = new SPAW_Wysiwyg( 'maintext', $maintext, 'en', 'full', 'default', '99%', '600px' );
$sw -> show();
xoopsSmilies("maintext");


Now I can create and article and I can look at it, but when I want to edit the article I see nothing ?
What did I wrong?
Thank you


5
CBlue
Re: How to use Spaw within your modules. Examples

Did you update the wfsection module after making your changes, svaha?

6
Mithrandir
Re: How to use Spaw within your modules. Examples

Since the Spaw editor is not using SMARTY, it shouldn't matter with updating after making these changes.

7
CBlue
Re: How to use Spaw within your modules. Examples

Okay! I find it never hurts to try updating modules though because you just never know!

8
disky
Re: How to use Spaw within your modules. Examples
  • 2004/1/3 20:58

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


Replace:
$sw = new SPAW_Wysiwyg( "maintext", $maintext, 'en', 'full', 'default', '99%', '600px' );
$sw -> show();

with:
$sw = new SPAW_Wysiwyg( "maintext", $this->maintext, 'en', 'full', 'default', '99%', '600px' );
$sw -> show();


Then it works :)

9
svaha
Re: How to use Spaw within your modules. Examples
  • 2004/1/3 23:45

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


@ Disky

10
shelley
Re: How to use Spaw within your modules. Examples
  • 2004/1/4 2:11

  • shelley

  • Just popping in

  • Posts: 31

  • Since: 2003/10/8


Thanks so many Catzwolf for the tutorial and the module!
Thanks svaha for all the "up"
I have modified the modules news and it works well.
I now have to try the other modules

a curiosity...
why only the admin you can use this editor?



Login

Who's Online

259 user(s) are online (129 user(s) are browsing Support Forums)


Members: 0


Guests: 259


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits