split $blogTitle or $entry.title into two

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

split $blogTitle or $entry.title into two

Post by carl_galloway »

Hi, I want to split $blogTitle or $entry.title at a word boundary so that I can wrap a span around the one of them. This would allow me to style the bit with the span with a different color or font size. Ideally I would like to be able to take the blog title/entry title and place the span after the second word, so the new html might look like this

this is <span> my new blog title </span>

Is this possible? The guys at the smarty forums have suggested creating a function or using modifiers but how do I do that?

Thanks, Carl
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: split $blogTitle or $entry.title into two

Post by garvinhicking »

Hi!

You would create such a smarty function in your template's config.inc.php file (see the tech docs on www.s9y.org for an example).

However.

Do you really need to go that route? Why do you want to use blogTitle? Why not use different fields alltogether? Hardcode the spans into your template file, use a Custom Entryproperty field for a "second" entry title? I guess that splitting a variable on word boundary might yield strange results in a dynamic way?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply