Page 1 of 1

how to add link to the post with an image

Posted: Tue Apr 18, 2006 2:02 am
by gizmotr
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

Re: how to add link to the post with an image

Posted: Tue Apr 18, 2006 9:49 am
by garvinhicking
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

Posted: Tue Apr 18, 2006 6:49 pm
by gizmotr
hey garvin ,

Yeah that is my last resort but I was wondering if I can link it when I create it rather then saving first getting the url and editing it :)

Posted: Wed Apr 19, 2006 5:08 am
by judebert
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:

Code: Select all

            <div class="serendipity_entry_body">
                {$entry.body}
            </div>
and replace it with:

Code: Select all

            <div class="serendipity_entry_body">
                {$entry.body|replace:'%extended%':"`$entry.link`#extended"}
            </div>
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.

Posted: Wed Apr 19, 2006 9:50 am
by gizmotr
oh makes a lot of sense ! I'll definetly try it tomorrow
Thanks a lot !

Posted: Wed Apr 19, 2006 7:48 pm
by gizmotr
okay , I tried this but I'm using a different template and i have this :

Code: Select all

 
            <div class="serendipity_entry_body">
                <?php echo $this->_tpl_vars['entry']['body']; ?>

            </div>
what can I do ?

Posted: Wed Apr 19, 2006 9:07 pm
by garvinhicking
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

Posted: Sun Nov 12, 2006 10:03 am
by clipmaster
does this "%extended%" work? anyone tried it?

... cause i tried it and i had no success :cry:

Posted: Mon Nov 13, 2006 7:40 pm
by judebert
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:

Code: Select all

<a href="%extended%">
<img blah blah blah />
</a>
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?