Trying to implement wysiwyg in SAEF - challenging!
Posted: 05 April 2008 03:26 PM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  436
Joined  12-22-2003

I’m working on this page on a client’s site (I’m calling this the “experimental page” in my description below). I’m trying to implement wysiwygPro editor in a stand alone entry form and I’m running into some errors that I don’t know how to solve (my php skills, which are required for implementing wysiwygPro, are rudimentary at best).

1. I’m also going to be asking the developer of wysiwygPro for his help, but he is not familiar with ExpressionEngine so I’m thinking it may take a combination of help from EE folks and him to ultimately solve the issues.

2. The page I’ve referenced above is experimental. Ultimately, what I’m trying to do is pull a stand alone entry form into the sidebar of the site so that people can post to one of 234 different weblogs from different parts of the site. I’ve been able to successfully implement that part of the project with a form which uses a dropdown menu of all the weblogs, XMLHttpRequest and url segments (to choose the correct weblog per the user’s choice from the dropdown menu) to pull in a stand alone entry form which will post to the user’s desired weblog.

3. This page has a working example of the stand alone entry form without wysiwygPro (you would have to click on the Tell Your Story header in the sidebar, but you would also have to be logged in as a member to access the stand alone entry form under that header - if you want to see it in action, let me know and I can PM a login and password). I’m calling this the “working example page” in my description below.

4. The basic template structure of both pages (the one with wysiwygPro and the one without it) looks something like this:

a. an index template (index_separate for the experimental page and index_separate_wowysiwygpro for the working example page) which lives in a template group called afghanistan. These are the basic templates for the pages.

b. a sidebar template (sidespot_expandable for the experimental page and sidespot_expandable_wowysiwygopro for the working example page) which I have embedded in the index template and which lives in a template group called sidespot.

c. a template for the stand alone entry form (submit for the experimental page and submit_wowysiwygpro for the working example page) which lives in a template group called site and which is loaded through XMLHttpRequest when the user selects an item from the drop down menu in the sidebar template.

5. Now I want to use wysiwygPro to add a text editor to the body and extended fields of the stand alone entry form. The directions for implementing wysiwygPro have two basic parts (there appears to be a lot more that you can do with it, but I want to at least get the basic editor working first before I start trying other stuff and I run into a roadblock immediately when trying to implement the basic editor):

a. Add a php include statement to your template. On the experimental page (in the index_separate template), I’ve added this code above the doctype in the index_separate template:

<?php

// include the WysiwygPro class
include_once("/wysiwygPro/wysiwygPro.class.php");

// start a session
session_start();

?>

b. Add php code to create the text area with the editor. I’ve added this code to the submit template to create the text area:

<?php

// create a new editor instance:
$editor = new wysiwygPro();

// configure the editor:

// give the editor a name
//(equivalent to the name attribute on a regular textarea):
$editor->name = 'field_id_2';

// set the content to be edited
//(equivalent to the value attribute on an input element or the content of a regular textarea):
$editor->value = '<p>some HTML code</p>';

// display the editor, the two paramaters set the width and height:
$editor->display('100%', '400');
  
?>
<!-- <textarea name="field_id_2" class="saeftextarea" rows="10" onclick="setFieldName(this.name)">
</
textarea> -->

As you’ll see, I’ve left the original text area and commented it out - this will show you what the code was that successfully created the text area without the editor (in the submit_wowysiwygpro template).

6. If you look at the experimental page, you’ll see this error at the top of the page (on the experimental page, I’ve made the background color white so you can see the error; I’ve also put some line breaks in the errors below so that it won’t create scrollbars):

Warning: Unknown(/wysiwygPro/wysiwygPro.class.php):
failed to open stream: No such file or directory in
/home/missio/public_html/blog/system/core/core.functions.php(637) :
eval()'d code on line 4

Warning: (null)() [function.include]:
Failed opening '
/wysiwygPro/wysiwygPro.class.php' for inclusion
(include_path='
.:/usr/lib/php:/usr/local/lib/php') in
/home/missio/public_html/blog/system/core/core.functions.php(637) :
eval()'
d code on line 4

and then if you were logged in and selected the Afghanistan option from the drop down menu in the sidebar, you would see this error (the exp:weblog:entry_form tag appears, :

{exp:weblog:entry_form weblog="afghanistan"
return="afghanistan/submitthankyou" preview="afghanistan/submit"}
--- snipping out some of the form labels ---

Fatal error: Cannot instantiate non-existent class:
wysiwygpro in /home/missio/public_html/blog/system/core/core.functions.php(637)
: eval()'d code on line 15

I realize that these issues are probably far outside the scope of normal EE support, so if it’s something you feel you can’t help me with, I’ll certainly understand.

Thanks,
Frank

Profile
 
 
Posted: 06 April 2008 08:14 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

I am going to shift to ‘How to’, since I’m not sure how much of an EE issue it is.  The only bit I’m fuzzy on EE wise is the session- not sure if that will run into a conflict or not.  And- for debugging?  I think I would ignore using the SAEF for the moment and just hard code a simple test form on a template- just to get the thing working there.  Then move to getting it working on a simple test page WITH the SAEF.  And once that works- try getting it in the sidebar like you want.  Always easier to move in small increments w/something giving you trouble.

And all that said- the big problem right now is the include- it’s not including wysiwygPro.class.php, so everything else is going to fail.  I’d check your path on that one- probably needs a dot or two at the start, or trying the full path.  Let’s see what happens once the include works.

ETA- and I edited your system folder name above- always good to keep that private.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 06 April 2008 01:13 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  436
Joined  12-22-2003

Thanks Robin!

No problem on moving the thread to “How To” - I debated when I first posted it.

I was able to do a simple test form without any problem (two dots was the solution). I was also able to set up a SAEF outside the sidebar and have it work. When I tried to bring it into the sidebar, however, I ran into problems. I was still getting the second error from my first post (thanks for editing the system folder reference - I hadn’t noticed that).

I ended up taking the include statement out of the index_separate template and putting it in the submit template (which holds the SAEF).

The result was that there were no errors any longer, the form loaded, but the editor did not load. I know it’s seeing the php because the text area with the name of “field_id_2” (which is now part of the second set of php code) is showing up.

So I’m thinking that the problem now is with XMLHttpRequest. The developer of wysiwygPro had told me before I purchased the script that he had some workarounds that would help with XMLHttpRequest, so we’ll see what he says (unless you know of something yourself!).

Thanks again!

Frank

Profile
 
 
Posted: 07 April 2008 01:08 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  436
Joined  12-22-2003

Okay, I’ve heard back from the developer of wysiwygPro. Here’s what he had to say:

Generally the problem with XMLHttpRequest implementations is that all they can do is display some html code on a page, when this happens any JavaScript code in that html is not run. So although you have probably added the WysiwygPro code to the page, that code has not been run. Your going to need to call a JavaScript function to activate WysiwygPro after it has been written to the page using XMLHttpRequest.

You need to find out from the Expression Engine team if there system provides a way to call a JavaScript function once an XMLHttpRequest has been completed. That is assuming your using some kind of framework included in Expression Engine for doing this stuff? If your not using an AJAX framework I suggest using xaJax: http://www.xajaxproject.org it is a framework for performing XMLHttpRequest (usually called AJAX) and makes it really simple to do amazing things with Ajax.

Any ideas?

Thanks,
Frank

Profile
 
 
Posted: 07 April 2008 10:33 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

Hm- I’m still a neophyte with the js, though I do at least follow what he’s saying.  EE isn’t really handling the js bits at all here.  It’s all in whatever code you’re using to deliver the correct form.  I’d say the next step would be to post how you’re doing that bit- may have to do it as an attachment to keep things intact.  But I’ll admit- I may not be much help on that end of things.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120594 Total Logged-in Users: 70
Total Topics: 126635 Total Anonymous Users: 35
Total Replies: 665682 Total Guests: 398
Total Posts: 792317    
Members ( View Memberlist )