Getting the Read More link on a different location.

Gravatar Michiel

  • Posts: 12
  • Topic Created: Wed Jan 25 08:37:28 2012 +0100

Hi :)

I've worked all trough the night converting my website to Chyrp. It's not finished yet, but I've come a long way. I downloaded the Read More Module, but can't figure out how to get the Read More link on a different location.

On the bottom of the posts I want to use it on there is an unordered-list with list-items. I would like to have the Read More link in a list-item in the unordered list.

Is there any way to get it do this?

You can see an example here: http://agosto.nl/chyrp/page/2 (first posts on that page).

"Bezoek website" (Visit website) is the link from a link-post. "Meer informatie" (More information) is the Read More link.

Currently it sits in its own unordered-list, but that's not how it is supposed to behave.

Gravatar Arian

Michiel, I just checked your site, and the more tag seems to be rendered just fine. Maybe I'm missing something in your question, but seemed fine for me.

Gravatar Michiel

Maybe I didn't explain myself correctly. Let me try again:

I changed the Module so that it displays a whole unordered-list with a list-item and anchor. That's all fine and dandy, but not really what I want. In for example a Link-post I already have an unordered-list with a list-item. I want to place the Read More link within that unordered-list; not a separate one.

Gravatar jack

Simple fix- open root/modules/read_more/read_more.php line 36 change to $string = __("

  • Read More »
  • ", "theme"); then in each feather wrap the read more with a ul, like

      ${ post.body | read_more }

    btw, very nice looking site ;)

    Gravatar Michiel

    It already says that. Am I doing something wrong? I can post some code.

    On the left: what I have. On the right: what I want.

    Oh and thanks :)

    Gravatar samuellittley

    Can you show us the code you have in your themes//feathers/link.twig file?

    Gravatar Michiel

    Sure:

    Attachments

    Gravatar samuellittley

    I've just realised how the read more module works... Only thing I can think of is to make the read_more filter just return the text and add a second filter to add the read_more link separately. Not sure how to set up twig filters though...

    Gravatar Arian

    Here, try this one out, should give how you want it rendered.
    http://snipt.net/tokolo/read_more?key=c33277903282de42c0ad3cb8826c0d55

    Gravatar samuellittley

    Okay, replace read_more.php with the attached version, then in twig use:

    ${ post.body | read_more("Read More Now") } to get the truncated post with the read more link as "Read More Now" (Optional Argument) ${ post.body | read_more_body } to get the truncated post with no link ${ post.body | read_more_link("li","Read More Now" } to get just the link in li tags as "Read More Now" (Both are optional arguments)

    If there is no marker, read_more_link will output nothing

    Attachments

    Gravatar Michiel

    Probably should have stated that I'm still on 2.1. Wanted to try that out before I burned my hands on the Beta ;)

    @samuellittley I can't seem to download the php file.

    @Arian: It now renders correctly, but it doesn't function. http://agosto.nl/chyrp/page/2 ${ post.description | read_more("<\ul class='buttons'> <\li><\a href='post.url' class='link'>Read More . . .<\/a><\/li> <\li><\a href='post.source' target='_blank' class='link'>Bezoek website<\/a><\/li> <\/ul>") }

    They both open a link; http://agosto.nl/chyrp/page/post.url and http://agosto.nl/chyrp/page/post.source respectively.

    • backslashes are because the forum would otherwise generate a UL in html :o

    Gravatar samuellittley

    twig doesn't parse fields inside arguments? try http://pastebin.com/GCqhQmM8

    and php file is attached as text below, just rename it to read_more.php

    Attachments

    Gravatar Arian

    Michiel, check the same link again: http://snipt.net/tokolo/read_more?key=c33277903282de42c0ad3cb8826c0d55

    It's the updated and working version of the tweak. I just tested and it works fine now. No need to alter read_more module just take the snippet.
    Let me know how it comes out now.

    Gravatar Michiel

    Both solutions work, sorta. Samuellittley's version does indeed render a li, but not within the UL that's already there.

    Arian, your version works best, but there is an error. When I go to the page (i.e. click the read more link) the visit website button also disappears. Which is kind of a problem :P

    Anyway to fix this?

    Gravatar samuellittley

    As for mine, where have you got the read more bit in the twig?

    Gravatar Michiel

    @samuellittley I used ${ post.body | read_more_link("li","Read More Now" }

    @arian your latest snippet did the trick. Works great now :D

    http://snipt.net/tokolo/read_more?key=c33277903282de42c0ad3cb8826c0d55

    I thank you both for the support and help :)

    Gravatar Arian

    @samuellittley and @Michiel get yourselves a nice looking gravatar for your emails. :P

    Gravatar Michiel

    I like my blueish weird looking thingy :+

    Besides that I'm not looking for jet another account somewhere :)

    Gravatar samuellittley

    gravatar just attaches to your email address, you can set multiple emails on one account... loads of things use it, just by matching hashed emails

    Gravatar AlisonW

    There's even a gravatar module for chyrp (or at least was and anyway I just finished upgrading it for 2.5b1 so will push it to my github either tonight or tomorrow, plus put the zip on my site.)

    Gravatar samuellittley

    I think gravatar is only currently baked in to the discuss system, not sure about comments...

    Where else would it be used?