Currently, when a page with a TOC appears in a teaser list an empty toc is created at the top of the teaser text (assuming the TOC is at the beginning of the page).
I currently have my users putting a 1 paragraph page abstract at the top of the page, then <!--break-->, then the ToC. Although this works, it's somewhat restrictive and artificial.
A much better solution would be to innately prevent the TOC from rendering on teaser pages. However, it seems that $teaser and $page are unavailable to filters.
This also relates to issue http://drupal.org/node/122064 for adding "Back to top" links as they also should not be rendered on teaser pages.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 191683_remove_teaser_5.x_9.patch | 1.76 KB | deviantintegral |
| #9 | 191683_remove_teaser_6.x_9.patch | 2.71 KB | deviantintegral |
Comments
Comment #1
deviantintegral commentedThe site I'm currently working on is using the except module so this doesn't really come up. But, this should probably be dealt with. I don't know if it's possible to change your input filter based on if its a teaser or not, anyone have any thoughts?
--Andrew
Comment #2
WorldFallz commentedI've looked at this a couple of times and done some googling, but I still haven't found any way to handle this.
Comment #3
casey commentedIt's pretty simple though:
Comment #4
WorldFallz commentedPardon my ignorance if this is a stupid question-- I'm pretty new to drupal and still trying to learn all the APIs--- there is a submit event prior to every listing of teasers?
Comment #5
casey commentedsubmit event is fired when a node is stored in the database.
Comment #6
WorldFallz commentedOIC said the blind man... now i get it. you're method actually removes the toc marker from the $teaser text when it's stored in the db. That sort of goes against drupal's philosophy of not altering the user text, but it's a teaser, which the user normally doesn't enter directly anyway, so I don't have a problem with it.
very cool....thanks for the solution.
@deviantintegral how do you feel about this solution? If you're amenable, I can test it out and roll it into a patch.
Comment #7
deviantintegral commentedThis looks like a reasonable solution. Please roll a patch and I'll be glad to test / apply. The regex should probably be defined somewhere so it can be easily changed.
--Andrew
Comment #8
deviantintegral commentedHere is a solution from casey's zip file:
This needs to be written up as a proper patch. I'd like to postpone this until 296171: Change Defaults? lands, as it involves a new setting. I'm going to suggest that this setting not be offered on a per-node basis, as it's almost guaranteed that you don't want the table of contents showing up in teasers.
Comment #9
deviantintegral commentedHere are patches for Drupal 5 and Drupal 6. The Drupal 5 version works as expected. However, the Drupal 6 version has some additional code to handle the D6 split teaser feature. I'm pretty happy with the D5 version, but I'd appreciate some additional testing for D6 before committing.
Thanks!
--Andrew
Comment #10
freatida commentedDrupal 5 version works well for me, thanks.
Comment #11
deviantintegral commentedThanks for the testing. I've applied this patch to both versions in commits #158739 and #158740.