22997 Posts in 11853 Topics by 2828 members
|Go to End|
13 March 2009 at 2:02pm
I want to add an image to my page.ss - what is the best syntax to use..
- Should $ImagenameImage print out a html tag for an image, if so what dir should it live in?
- Where should I put images that part of a template but not called from CSS?
13 March 2009 at 2:13pm Last edited: 13 March 2009 2:13pm
I'm not sure I totally understand you question.
There are a couple of ways to add images in your tempalte, the most common being;
$Image - this will add a complete image HTML like <img src="myImage.jpg" alt="Image name" >
$Image.URL - this will return the URL so that you can use your own tag like so: <img id="img" src="$Image.URL" alt="some proper text" >
you can also resize images in the template:
Unfortunately you cant then add .URL on the end, so if you want to resize and only use a url then you need to do somthing like this:
<% control Image %>
<% control CroppedImage(100,100) %>
<img src="$URL" alt="some text" >
<% end_control %>
<% end_control %>
Hope that helps
13 March 2009 at 3:07pm
Thanks for the reply.. I guess I mean..
I have an image in '/themes/MyTheme/images/theMoon.jpg' but in order to put it in the template I want the path to work properly (I am rewriting my baseurl). In cakePHP I would have used the image helper...
echo $html->image('title', 'path')
...and it would automatically add the right root url.
Does that make sense?
13 March 2009 at 3:24pm
If the image is part of your template, you can call it like Aram said, only use the $ThemeDir global var to refer to the current theme directory. If the image is part of the model, however, you can call it using its fieldname.. e.g. $MyImage, which will render an image tag for you. Otherwise, for a custom tag, you can do img src="$MyImage.URL" alt="" etc...
Helpers, despite all their admirable attempts to streamline development, break the MVC pattern and should be avoided when possible.
18 March 2009 at 5:16pm
Im a newbie too, and I am having the same trouble.. Thanks for posting.. So psyched to be here!
|Go to Top|