 |

glevine
User
Mar 18, 2008, 8:31 AM
Post #1 of 2
(307 views)
Shortcut
|
|
Replacing part of a string
|
Can't Post
|
|
Is there a way to replace only part of a string using one of the placeholder modifiers? I'm trying to add a photo of the author at the template level and I want to avoid using javascript. The photo filenames are the author's full name without spaces. The code I was trying to use was:
<img src="/photos/$article.author:lowercase:replace(' ','')$.jpg alt="$article.author:htmlEncoded$" align="right" /> Unfortunately, this was a misuse of replace. Replace matches the entire string in the placeholder, not a substring. Is there any way to do what I was attempting? Thanks
|
|
|  |
 |

Donna
Staff
/ Moderator

Mar 18, 2008, 1:38 PM
Post #2 of 2
(302 views)
Shortcut
|
|
Re: [glevine] Replacing part of a string
[In reply to]
|
Can't Post
|
|
Hi there, Replace won't work the way you're expecting as that will only match the entire value. However, there are a few ways you could get around that. One, if you've got a limited number of authors, you could simply create a pre-defined dropdown field for each of your author images, and have the "value" set to the filename for that author. Alternately, you could use the ":urlEncoded" option, and save the files as Firstname%20Lastname.jpg ("%20" being the URL encoded value for a space.) Would either of those methods work for you? Donna
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
|