[development] HTML in node titles for D5

Andrew Fountain af at loveintruth.com
Mon Jan 21 04:23:43 UTC 2008


There is an added complication with a link in a node in that when the node
is presented as a teaser, it will already be a link to the full node page.
Because of this we can only implement the hyperlinks when the browser is on
the full node page.

If we assume the simplest situation where the *whole node* is a link, I
would suggest using "[" and "]" as delimiters, something like this:
original node: *text of node [url]
*on node page after processing: *<a href="url">text of node </a>*
on teaser page after processing:* text of node*

In a more complex situation where you want arbitrary words in the node to be
hyperlinked, you can extend the sytax slightly with something like:
original node: *This is my node [with linked text:url] in it*
on node page after processing: *This is my node <a href="url">with linked
text</a> in it* on teaser page after processing: *This is my node with
linked text in it*

I haven't yet written the specific regular expressions you would need for
the above syntax. Sometimes it is best to adjust the sytax to make it easy
to write the regex.

On Jan 20, 2008 9:40 AM, Walt Daniels <wdlists at optonline.net> wrote:

> I also need this but what I need is a link. Perhaps [text:url] or
> something
> similar could be changed to <a href="url">text</a>. Is this secure, given
> that text:url has been though checkplain?
>
> -----Original Message-----
> From: development-bounces at drupal.org [mailto:
> development-bounces at drupal.org]
> On Behalf Of Yuval Hager
> Sent: Sunday, January 20, 2008 12:12 AM
> To: development at drupal.org
> Subject: Re: [development] HTML in node titles for D5
>
> On Sunday 20 January 2008, Andrew ft wrote:
> > Please tell me if this is a bad idea, but how about this as a solution:
> > If you are only interested in minimal markup, like the ability to use
> the
> > <em> tag, what about using a special character to indicate it in the
> node
> > title, and then processing the title at the theme layer (for example
> with
> a
> > regular expression) to convert the characters into tags.
> > For example, you could use Hello *World!* as the node title and then
> > convert this with a simple regular expression to Hello <em>World!</em>
> when
> > the node is rendered.
> > This would have the added advantage of keep clean the RSS feed from the
> > node. It would also be much shorter than putting markup in the title,
> > bearing in mind the 255 char limit.
> > Would this be classified as a hack?
> >
>
> That's a very good idea! It has the advantage that in all places that
> output
>
> check_plain($node->title) will show a reasonable string after all.
> As long as the required markup is limited - this is the most elegant
> solution
> I've seen!
>
> Thanks,
>
> --yuval
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.7/1233 - Release Date: 1/19/2008
> 6:37 PM
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.7/1233 - Release Date: 1/19/2008
> 6:37 PM
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080120/25ebbd6e/attachment-0001.htm 


More information about the development mailing list