17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1311 Views |
-
Trying to create custome image SRC field from $Title

2 October 2008 at 9:50pm
I want to reference images based on page titles as in:
<img src="$Title.jpg" />
How can I escape the $Title part so that it would render the page title and extension as one string. As in Home.jpg
Is this possible?
-
Re: Trying to create custome image SRC field from $Title

2 October 2008 at 9:54pm
You need to add { } around the variable to tell SS what it is. Eg at the moment it will be looking for a field $Title.jpg which is wrong. You need to do {$Title}.jpg
-
Re: Trying to create custome image SRC field from $Title

2 October 2008 at 10:02pm
Thanks for the quick reply...
Would this be the 'correct' way to do something like this.. I can't maybe create a custom property from the controller side that would add the extension and output the final string and just call it as something like $TitleImage?
I'm still fairly new to this great CMS and mvc concepts
-
Re: Trying to create custome image SRC field from $Title

2 October 2008 at 10:14pm
You could do but that would be over designing it. Tho the 1 thing I would say is you can have spaces in titles, a safer option would be to use $URLSegment which would return things like 'home', 'about-us', 'blog' etc and $URLSegment doesn't has spaces - Images URLs would fail with spaces.
| 1311 Views | ||
|
Page:
1
|
Go to Top |


