It would be usefull to have a button to insert the <!--break--> sequence into a text.

Comments

jsaints’s picture

I am looking into how to do this now. anyone else done it? or working on it?

Thanks

matt westgate’s picture

Title: REQ: A way to insert a teaser break in the content » A way to insert a teaser break in the content
Version: 4.6.x-1.x-dev » master

Until a button is created, you can switch to the source view and add a <!--break--> where you need to.

matt westgate’s picture

Anybody want to take the lead on this?

anders.fajerson’s picture

StatusFileSize
new903 bytes

Here is a quick and dirty patch to insert

to a textarea.

Here are some (not coded) ideas for improvements:
* make it a button instead of a link that can be enabled in the advance theme
* insert something like


so the break will be visible in the textarea
* remove the


when the node is saved, either with tinymce's save_callback (if that's possible) or with drupal
ahoeben’s picture

StatusFileSize
new1.08 KB

Here's the beginning of a tinymce plugin for a button that inserts a

sequence.

It works ok-ish in Firefox, though you don't get any visual feedback. Internet Explorer however seems to filter the HTML comment right out of the contentEditable tinyMCE html.

So the plugin should be refactored to instead of inserting the sequence immediately, it should insert a placeholder graphic. Upon saving the placeholder should be replaced by the actual sequence. Ideally, when loading a node back in tinyMCE, the sequence is replaced with the placeholder again. Can tinymce do that?

the attached plugin doesn't do anything like this, but may serve as a starting point

ahoeben’s picture

StatusFileSize
new2.31 KB

See attached archive, which includes a patch to tinymce.module, as well as a new plugin named "drupalteaserbreak". This plugin must be moved to the tinymce/jscripts/tiny_mce/plugins folder.

The plugin implements the method I outlined above, and works with these two caveats:

  • if you insert multiple breaks in the content, the replace is so 'greedy' that it removes the part of your content between the break sequences. I am not that regexp saffy...
  • if you view the source/edit html/disabled rich editing, you will see the image placeholder

PS: Sorry about the bold before, that came out to shouty.

ahoeben’s picture

Status: Active » Needs work

Turns out the plugin 'eats' images that are included before the break. Needs work

anders.fajerson’s picture

The wordpress team did it. Check out http://asymptomatic.net/wp/2005/08/18/1898/better-every-day/. The plugin is here: http://trac.wordpress.org/ticket/1564. I've tried it with the TinyMCE module and it works flawlessly, the code just need to be made more Drupal specific (replace more with break and remove nextpage code). I would have made a patch if I could...

quicksketch’s picture

StatusFileSize
new5.19 KB

Props to fajerstarter for pointing out the excellent plugin by the Wordpress team. I've modified this plugin to include both break and pagebreak comments (which may be seperately included in the toolbar). I've tested in out in IE and FF with great success. I've never used the pagination module before, but it is available in this forum (thanks ahoeben). Make sure you both enable the plugin in tinyMCE and enable the buttons within the toolbar.

i.e.

  tinyMCE.init({
    ...
    plugins : "drupalbreak",
    theme_advanced_buttons3_add : "drupalbreak,drupalpagebreak"
    ...
  )}

Of course you'd want to include other buttons and plugins. Let me know how it works for everyone.

noid’s picture

Hi quicksketch,

I added your drupalbreak to the "plugins" folder (placed the drupalbreak folder there) and modified tinymce.module such that:

  tinyMCE.init({
    $tinymce_settings
plugins : "drupalbreak",
    theme_advanced_buttons3_add : "drupalbreak,drupalpagebreak"
      });

It's not yet working. Am I doing things right? How do I include the buttons? Is there a code somewhere that I have to add? Is there a semi-colon missing in the code? Thanks in advance!

quicksketch’s picture

noid,
Which version of tinymce.module are you using? I'd also say that directly adding the code where you have it probably isn't optimal. Rather than appending the code directly, it'd be better if you modified the contents of the variable "$tinymce_settings" and left that segment of code alone.

Do a search on the tinymce.module and look for "$init['plugins']". There should already be a few values set and simply append drupalbreak to the list. There are several variables set at this point, my list looks like this:

  $init['mode']               = $status == 1 ? 'exact' : 'none';
  $init['theme']              = $settings['theme'] ? $settings['theme'] : 'simple';
  //$init['document_base_url']  = "$base_url/";
  $init['remove_script_host']  = "true";
  $init['relative_urls']  = "false";
  $init['plugins']  = "contextmenu,drupalimage,drupalbreak";
  $init['browsers']  = "msie,gecko,opera";
  $init['inline_styles']  = "true";
  $init['remove_linebreaks'] = "false";
  $init['convert_fonts_to_spans'] = "true";

I don't add the button to the toolbar in my list (I've done it elsewhere), but you could do this by adding:

  $init['theme_advanced_buttons3_add'] = 'drupalimage,drupalbreak';

You can change the row the buttons are added to by changing "buttons3" to "buttons2" or 1.

Check the readme file included with the plugin for more instructions on including the plugin. Let me know if this helps and if you get it to work (and what you did). More info about tinyMCE settings like these are available at http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html.

robert castelo’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new85 bytes

Here's a button image for the teaser break.

m3avrck’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new6.53 KB

While I would like to commit this as part of the CVS version of TinyMCE, I am having a bit trouble with it. Attached is a zip file with updated code from quicksketch. I've modified the code slightly so that it will work with TinyMCE 2.0 and the CVS version of tinymce.module. Installation is *much* easier with the CVS version of tinymce.module and I've updated the README accordingly. Getting this basic plugin to work with CVS is pretty trivial.

However, a few issues need to be dealt with before I would include this in the plugins/ directory of tinymce.module.

1. Preview/Submit does not work. I am getting some sort of infinite loop that eats up all the memory of FF and it just crashes. This has to be dealt with, I suspect either the regex could be wrong or the pagination module isn't working too great.

2. The pagebreak and break images in FF are broken. For some reason the space.gif is not found, however in IE6 this is found. Not a deal breaker but this should be looked into.

3. Pagination module isn't fully compliant with Drupal CVS. Since tinymce.module CVS is poised to be 4.7 ready, I am hesistant about including a plugin that *won't* work with CVS. I'd like to see this module updated somewhere (contrib would be great!) too.

But for now though, if anyone wants to play with this plugin, extract the attached zip file into tinymce/jscripts/tinymce/plugins directory and enable it from the admin menu. Make sure you are running Drupal CVS (or 4.7) and tinymce.module CVS ... otherwise this *won't* work.

quicksketch’s picture

This all sounds good. I downloaded and installed a fresh Drupal and tinymce module (both cvs) and installed the the drupalbreak plugin. Unfortunately, it doesn't seem to do much at all. Besides inserting the image placeholder, it doesn't do anything. Did you have any better luck when you installed it?

It has the following functionality with the 4.6 release versions of Drupal and tinymce.module:
- Inserts an image placeholder for either < !--break-- > or < !--pagebreak-- > (works in cvs)
- Automatically converts placeholder back to breaks when HTML source is viewed
- Automatically converts placeholder when editor is disabled (user clicks on "disable rich text")
- Converts to breaks when node is previewed or submitted

The following setup works as described:
tinymce.module,v 1.38
drupal 4.6.3
tinyMCE 2.0 RC4

I'm using the following in the CVS testing:
tinymce.module,v 1.44
drupal cvs (updated 11/29/05)
tinyMCE 2.0 RC4

quicksketch’s picture

StatusFileSize
new4.37 KB

Okay, I found my above problem. tinyMCE had been filtering out the placeholder image's "name" attribute. Possibly because name is not a valid XHTML 1.0 strict attribute for an image (I believe). I removed the name attribute and depend on the "class" attribute instead.

About the missing images, I think that this is probably related to tinyMCE's tendency to change links and urls to be relative to the tinyMCE installation or the current page. See http://drupal.org/node/32320 for more on this problem.

So, the bottom line is this plugin should work with the CVS (and any) release of tinyMCE.module.

The updated README file looks good, and I have to agree that the CVS tinyMCE makes enabling plugins much easier. Until 4.7 is released however, I'm sure that many users (like myself) will use 4.6 for production websites.

m3avrck’s picture

Ah, marvelous! Just tested this and it works *much* better. Preview/Submit *now* works, no nasty infinite loop/browser crashes, yay! As for the images in FF, I tried that URL but that didn't help. The problem is in FF *only* and if you disable then enable rich text, the spacer gif is loaded, so it is being correctly found, just on the 2nd try. I'll shoot the TinyMCE guy an email to see if he knows about this problem, seems pretty interesting.

Otherwise definetly seems to be working with CVS versions of Drupal and tinymce.module, bravo! I'll talk with the other committers and see if we want to include this in the plugins directory of the downloadable module, thanks!

And oh, someone should make that pagination module a contrib module and update for 4.7 (should take all of 10 min to do that), *hint, hint* ;-)

m3avrck’s picture

Status: Needs work » Fixed

Thanks!

Been talking with the main TinyMCE developers and we have fixed the path issue. The fix will be present in the final release of TinyMCE which is due out in the next day or two. That with the other fixes and everything is working great so I've added this plugin to CVS and it will be released with 4.7. Very easy to setup, just need to grab that pagination module.

And oh, I used the following script to compress the JS file:
http://alex.dojotoolkit.org/shrinksafe/

And if anyone wants to make that pagination module a contrib module that would be awesome! :-)

quicksketch’s picture

Fantastic. This will make tinyMCE even more desireable to Drupal users. I'm looking forward to the new 2.0 release of the editor. Which should clean up the last few small problems. Thanks for adding to cvs, it looks great.

Anonymous’s picture

Status: Fixed » Closed (fixed)
budda’s picture

Version: master » 4.6.x-1.x-dev
Status: Closed (fixed) » Active

The plugin doesn't seem to work with TinyMCE 2.0.3 - Moxie mention that their plugin architecture has changed to be OOP now, but old plugins should still work as they are wrapped in an object.

quicksketch’s picture

Assigned: Unassigned » quicksketch

I haven't yet gotten a chance to look into this, but expect a fix soon. I know that this plugin works fine with tinyMCE 2.02, but I haven't yet gotten a chance to update to the latest version. Funny that a .01 update would change so much. Anyway, it looks like the new code from moxiecode is much improved, so hopefully that will mean a much more efficient plugin when I update it. Thanks for the update.

budda’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new7.71 KB

Please find attached an update drupalbreak plugin (v1.2) to work withthe new TinyMCE 2.0.3 plugin API.

Tested in FireFox and IE6 without any JS errors.

It's the _src version which hasn't been optimized/compressed.

m3avrck’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! I've committed these changes along with adding a compressed JS file. Should be good to go now, please reopen if you have any more issues.

Anonymous’s picture

Status: Fixed » Closed (fixed)