Adding "Read More" Link in Article.

Discussion in 'PHP' started by saadi123, May 29, 2010.

  1. #1
    Using MySql, SQl and PHP, I want to add "read more" link to my articles. Does any body has an idea how to do it?
     
    saadi123, May 29, 2010 IP
  2. systemick

    systemick Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Couldn't you just hard code the first x words then add the link. Can you tell us more about exactly how you want this to work?
     
    systemick, May 30, 2010 IP
  3. teguhaditya

    teguhaditya Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if you use wordpress (php cms) you can add <!--more--> on your post. read more link will be automatic generate
     
    teguhaditya, May 30, 2010 IP
  4. saadi123

    saadi123 Well-Known Member

    Messages:
    196
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    Hard coding is too laborious as I will have to do this for every article. I need some automation.
    What I am trying to ask is that the main page has only a little portion of the article. which ends with anchor texts like "Read More, Continue Reading" e.t.c Upon clicking this text, I am guided towards the full article. The only thing I have to do is just to submit my article in the database and the rest of the work is done by the coding. I hope this clears a lot.
     
    saadi123, May 30, 2010 IP
  5. saadi123

    saadi123 Well-Known Member

    Messages:
    196
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    I know this can be done very easily in wordpress and many other CMS. What I am asking is to have my own.
     
    saadi123, May 30, 2010 IP
  6. abstractworld

    abstractworld Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can use substr function to cut down the string and at the end add the link where you are showing complete page...
     
    abstractworld, May 30, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    Post the code which displays your articles, so we can help you.
     
    danx10, May 31, 2010 IP
  8. wigwambam

    wigwambam Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    // Display, say, 200 characters of article.
    echo substr($content_story,0,200) . "...<br />";

    // Add link.
    echo "<a href='link.php?id='" . $id . '">Read More</a>";
     
    wigwambam, May 31, 2010 IP