Hey ,
I have an image for every single post I make and I would like to users be able to click on the image to read the details of the article. How can I do this ?
Thanks
how to add link to the post with an image
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: how to add link to the post with an image
Hi!
So you insert an image into the "body text" for your entry, and then insert the text you want your users to read into the "extended body"?
You can just wrap a link around an image (<a href...> or via the WYSIWYG editor), but first need to save the article to get it's future URL...?
Best regards,
Garvin
So you insert an image into the "body text" for your entry, and then insert the text you want your users to read into the "extended body"?
You can just wrap a link around an image (<a href...> or via the WYSIWYG editor), but first need to save the article to get it's future URL...?
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/
# 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/
I use permalinks to know the URL of the article beforehand. Then the link is just <permalink>#extended.
If the image always goes in the same place, you might be able to do this with a few changes in the entries.tpl and an extended property to hold the image.
Finally, consider a simple Smarty bit in the entries.tpl. Find this bit:
and replace it with:
Be careful with the backticks and things; I haven't tried this yet myself, but the Smarty docs say it'll work.
Then you can just make your image with <a href="%extended%">, and it'll be replaced with the extended entry link. Only drawback is that %extended% will be replaced everywhere else in the body, too. Choose your marker wisely.
If the image always goes in the same place, you might be able to do this with a few changes in the entries.tpl and an extended property to hold the image.
Finally, consider a simple Smarty bit in the entries.tpl. Find this bit:
Code: Select all
<div class="serendipity_entry_body">
{$entry.body}
</div>
Code: Select all
<div class="serendipity_entry_body">
{$entry.body|replace:'%extended%':"`$entry.link`#extended"}
</div>
Then you can just make your image with <a href="%extended%">, and it'll be replaced with the extended entry link. Only drawback is that %extended% will be replaced everywhere else in the body, too. Choose your marker wisely.
okay , I tried this but I'm using a different template and i have this :
what can I do ?
Code: Select all
<div class="serendipity_entry_body">
<?php echo $this->_tpl_vars['entry']['body']; ?>
</div>
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Are you sure you are editing *.tpl files and not *.tpl.php files? The output you relate to usually is only found in the templates_c folder. Do not touch these files. Only edit the files in templates/.
Regards,
Garvin
Are you sure you are editing *.tpl files and not *.tpl.php files? The output you relate to usually is only found in the templates_c folder. Do not touch these files. Only edit the files in templates/.
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/
# 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/
-
clipmaster
- Regular
- Posts: 6
- Joined: Wed Nov 08, 2006 7:12 pm
I haven't really tried it yet, but I realize that my instructions may have been non-intuitive. Here's the breakdown:
1) Edit entries.tpl (as described in previous post, such that any occurrence of "%extended%" is replaced by the URL of the extended body).
2) Create a new entry; this was stipulated in the question to be a single image.
3) Wrap the image in an anchor, thusly:
4) Save the entry.
When you next look at the entry, Smarty should change the anchor hyperlink you just created with the actual URL of the extended body.
Which step is failing?
1) Edit entries.tpl (as described in previous post, such that any occurrence of "%extended%" is replaced by the URL of the extended body).
2) Create a new entry; this was stipulated in the question to be a single image.
3) Wrap the image in an anchor, thusly:
Code: Select all
<a href="%extended%">
<img blah blah blah />
</a>
When you next look at the entry, Smarty should change the anchor hyperlink you just created with the actual URL of the extended body.
Which step is failing?