Allow read more link to be inserted into wider range of elements

dboulet - August 21, 2009 - 18:40
Project:Read More link (Drupal 6 and earlier)
Version:6.x-5.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Todd Nienkerk
Status:closed
Description

As far as I can tell, this module tries to insert the read more link inline by searching for a closing paragraph tag that is located at the end of the teaser text string. This means that the link will not be inserted at the end of a paragraph tag which is wrapped in some other element, such as a div. The modifications in this patch serve as an attempt to improve the regular expression used, by having it match a closing paragraph tag which can be followed by any number of closing HTML tags.

AttachmentSize
ed_readmore-HEAD_regex.patch872 bytes

#1

Todd Nienkerk - August 23, 2009 - 00:23

dboulet: You're exactly right when you note that this module only inserts code after a closing <p> element. Deviating from this raises a difficult question: Inside which elements should the link be inserted? What if adding the link inside the <div> that wraps the <p> results in displaying the link in a non-contextual way?

Consider, for example, <blockquote>. Adding a link inside a blockquote isn't contextual: It implies that the "Read more" link was originally part of the quote. Quite a pickle, eh? :)

It just occurred to me that we should add a an option that allows users to choose the elements in which the link will be inserted. Instead of trying to come up with use cases for all -- an impossible task -- we should simply let site admins choose for themselves.

#2

dboulet - August 24, 2009 - 17:58

Ha, I should've known that it wasn't going to be that simple ;).

An option to allow admins to choose into which elements the link will be inserted sounds like a good option to me.

#3

dboulet - August 24, 2009 - 18:24
Title:Regular expression improvements» Allow read more link to be inserted into wider range of elements
Status:active» needs review

Here's a quick first draft of the previously mentioned admin setting.

AttachmentSize
ed_readmore-HEAD_inline_elements_setting.patch 2.08 KB

#4

Todd Nienkerk - September 15, 2009 - 20:22

dboulet: Would you mind re-rolling this patch against the latest commit in 6.x-5.x? I've made some changes today that conflict with your patch, and I'd like to get your opinion on how to resolve them.

(HEAD is out-of-date. Avoid it!)

#5

dboulet - September 15, 2009 - 20:39

Try this one.

AttachmentSize
ed_readmore-DRUPAL-6--5_inline_elements_setting.patch 2.07 KB

#6

Todd Nienkerk - September 15, 2009 - 23:04

dboulet: This looks great. Thanks!

Instead of allowing the user to add these elements directly, how do you feel about providing a list of candidate elements that the user can check off? I've attached a patch.

Also, I'm curious to know why you omitted ?: from the $block_tags var in your diff. I'm not too familiar with regex, so forgive my ignorance.

AttachmentSize
ed_readmore-DRUPAL-6--5_inline_elements_setting_2.patch 4.88 KB

#7

dboulet - September 21, 2009 - 15:01

@Todd, I guess your method is a little more foolproof, though less versatile. That's probably fine—I'm guessing that 99% of people are only going to choose p and div elements anyway.

As to the omission of ?: from the group of elements, I just didn't see why it was needed, so I left if out.

#8

Todd Nienkerk - September 21, 2009 - 15:06

dboulet: As your regex skills are sharper than mine, I'll take your word that the removal of ?: won't be detrimental.

I'll commit this change later today. Thanks for your input!

#9

Todd Nienkerk - November 10, 2009 - 04:59
Status:needs review» fixed

A slightly modified version of dboulet's patch was added and committed to 6.x-5.x-dev. Thanks!

#10

Todd Nienkerk - November 10, 2009 - 05:01
Assigned to:Anonymous» Todd Nienkerk

#11

System Message - November 24, 2009 - 05:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.