Drupal recognizes the --break-- tag as a separator between teaser and body. It would be nice to if htmlarea.module had a custom button for tag. A reasonable icon for this button might be '--'. Custom buttons are pretty easy with HTMLArea.

CommentFileSizeAuthor
#16 ed_break.gif1.14 KBrobert castelo
#5 htmlarea.module17.97 KBsofiya

Comments

gordon’s picture

Assigned: Unassigned » gordon

Yes this is on the list, I need to finish some other changes and then I can add this feature.

gordon’s picture

I have been doing some more thinking about this one, what I am thinking of doing is adding an additional tab that will allow you to write javascript to create such a custom button.

sofiya’s picture

What I did, was put a 'Teaser Breaker' icon in HTMLArea toolbar and the user has just to position the cursor in the body field where he/she wants to end the teaser and press the 'Teaser Breaker' icon. A MARK then appears in the HTMLArea that signifies a 'teaser break'. My teaser marker is "[TEASER BREAK]". I do away with

because HTMLArea.js ignores 'comments' and strip them.
This just requires a two_lin_patch in htmlarea.module. I then replace all occurences of

in node.module to my TEASER MARKer. :)

gordon’s picture

this bug that caused comments to be stripped has been fixed.

How did you add the additional break button?

sofiya’s picture

StatusFileSize
new17.97 KB

this bug that caused comments to be stripped has been fixed.

is this fix came from interactivetools.com or a hacked htmlarea.js to allow comment like

?

This is how I added the customized button in htmlarea.module 4.4.0.

  • in function htmlarea_textarea($name), after line 144, i put this line of code:
    $htmlarea_fields[] = " $name.config.registerButton(\"my-teaserbreak\", \"Insert a Teaser Break\", \"misc/htmlarea/images/my-teaserbreak.gif\", true, function(editor, id) { editor.insertHTML('[TEASER BREAK]'); });";
  • and in function _htmlarea_defaults($field), in line 300, i added in the array the name of my teaser-break, ,"my-teaserbreak"

i also created a simple icon that indicates that's it's a teasear break. :)

attached is a patched htmlarea.module that has a customised teaser-break button. (sorry i dont have a cvs front-end, i cant diff )

hth.

gordon’s picture

I knew that the process to do this is extremely simple. This is why I am thinking of adding a custom page that will allow you to enter js code into attacheditor() so that it will appear on the screen. Then you will not have to patch htmlarea to add this code.

Jhef.Vicedo’s picture

Or would a plugin(htmearea) be good for this? So there will be no patching on htmlarea script.

I already created a plugin but I am wondering if the --break-- comment is already fixed? You mentioned above, it is but on which version? Is it on the cvs or is it included in the 4.5rc version of #drupal?

gordon’s picture

I have added a new tab to the settings menu called custom js. This will enable the administrator to add additional code the the attacheditor() right before the editor.generate().

This will mean that custom buttons will be able to be created here.

gordon’s picture

Title: Add custom button for --break-- » Add custom button for <!--break-->
kbahey’s picture

Hi

Thanks for this generic function. It will be very useful for sure.

More specially though, can someone paste some js code here that inserts a --break-- comment?

This will truly bring closure to this issue.

kbahey’s picture

Changing to active so the details of how to get a break key be posted before closure.

gordon’s picture

If someone can post an nice Icon for it I was actually add it to the help of the js entry screen. so you can cut and paste it.

gordon’s picture

I have now changed this to fixed, as the actual code is in commet #5, you just need to change the [TEASER BREAK] to <!--break-->

Anonymous’s picture

robert castelo’s picture

Could someone please post the javascript that should be copied into the custom js field - exactly as it should be used.

I tried to use the script in comment 5 above, but as I don't know Javascript I couldn't get it to work.

I'll be able to supply a button image for this soon.

robert castelo’s picture

StatusFileSize
new1.14 KB

Here's an icon for the 'break' button.

Now, could someone supply the JavaScript?

wvengen’s picture

Well, I placed your image in modules/htmlarea/xinha-nightly/images/ and entered the following in the custom javascript textarea:

editor.config.registerButton("my-teaserbreak", "Insert a Teaser Break", _editor_url+"/images/ed_break.gif", true, function(editor, id) { editor.insertHTML('&lt;!--break--&gt;'); });
editor.config.toolbar.push(['my-teaserbreak']);

You need to replace &lt; and &gt; with < and > respectively in the code above.
It adds a teaser break button, but the teaser break is not visible when entered :(

gordon’s picture

Status: Needs review » Active

I think that I (or someone else) is going to need to create a plugin for Xinha to allow this.