Random ...
 
December 2017
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Tags ...
Links



python+zope++:: Adding Epoz to your textarea and how a typo resulted in 2 hour waste :P
Posted at 20.Jul,2005 14:18  Comments 0 / Trackbacks 0 / Like this post!
Technorati tag(s):

I've always wanted to add an HTML wysiwyg editor into my custom ZClass application. Well, today I finally did it.

First, get Epoz

untar in your zope products directory, and restart zope.

Now anywhere in your form where you have textarea and want to replace with Epoz, add the following:

       <dtml-var "Epoz('your_textarea_name',
                           data=''),
                           toolbox='atoolbox',
                           lang='en',
                           style='width: 620px; height: 450px;')">

Replace your_textarea_name with the necessary field name. And if you have a predefined data anywhere, just do:

           data=your_var

Now, the interesting thing is using toolbox, or in my case, I renamed it to atoolbox.

Create a DTML Method in your Root Folder:

         <html><body onload="this.focus();">
          <i><dtml-var absolute_url></i>
         <br>
         <a href="<dtml-var   "PARENTS[1].absolute_url()+'/atoolbox'">">Up to   parent</a>
         <dtml-in expr="objectValues(['Folder','Folder (Ordered)'])" prefix=seq>
         <br>&raquo; <a href="<dtml-var "absolute_url()+'/atoolbox'">">&dtml-title_or_id;</a>
         </dtml-in>   
         <hr>
         <br><b>Images</b>
         <br>Images available:
         <p>
         <dtml-in "this().objectValues(['Image','Photo'])">
         <img src="<dtml-var absolute_url>"
        border="0"
        alt="<dtml-var title_or_id>"
        style="cursor: pointer;"
        onclick="window.opener.CreateImage('<dtml-var   "'/'+'/'.join(absolute_url().split('/')[3:])">'); window.close();">
        <dtml-var "'/'+'/'.join(absolute_url().split('/')[3:])"> 
        <br><hr> 
        </dtml-in>

         <hr />
         </body>
         </html>

That's it.

I talked about how a typo bugging me; it was this:

      onlclick="window.opener.CreateImage('<dtml-var absolute_url>'); window.close()
;">

which I copied from README.txt, and never checked until I ran out of ideas :P. Well, there are two lessons here:

1- Always check the obvious

2- I can now send a patch to Epoz author :))

3- Use the same version. :P I read the README for version 0.5. So scratch #2

I deserved it, methinks.

Have fun!


Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/36/tbping 

Comments
Post a comment