SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to add 'read more' link in article using simple CMS with WYSIWYG editor

    I am adding some CMS functionality to a client site that I developed several years ago. The vast majority of the site is static however there are quite a few pages.

    Anyway the client has asked to add a few new sections that need to include articles that the client will add to the site. The articles will include both text and images.

    One of the requirements is that the article page displays several articles at once, with only some of each article displayed with a 'read more' link to navigate to read the full article. The article content that is displayed is not any fixed number of paragraphs or number of words but is arbitrarily decided by the client.

    I therefore need a means of having an admin page to add an article that allows me to specify where the 'read more' link goes.

    I was thinking of using the TinyMCE editor but not sure how I would add this "read more" link.

    Any advice appreciated!

    Thanks

    Paul

    p.s I am not interested in using a CMS like Joomla for this as this would involve recreating the entire site in Joomla - which I would imagine would take ages including the learning curve.
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,293
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    This might be a good role for WordPress to play. It is a blog/article CMS that works nicely as a section of a website if you want it to. It's easy to install and set up.

    There are other CMSs out there that are small and well suited to integrating into an existing site. Perch is a lovely example of such an one.

  3. #3
    SitePoint Zealot Jaanboy's Avatar
    Join Date
    Sep 2007
    Location
    UK
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you not just use a tag like {read_more}. Then when displaying several articles, only show the content before the tag. When viewing the full article, take out the tag and show everything?

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Just give them a text box, decorate it with a wysiwyg editor if you want, then just chop off the first x characters and use that as the "intro".

    I tend to create a separate "intro" text area, max say 120 chars - and spell out to them on the GUI that this is very important, must work as a teaser etc etc.

    Focusses the editors on thinking harder on what the importance of the intro instead of just blathering on.

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the replies.

    The client has supplied the copy for these articles already and it is a case of splitting the articles at the end of specific paragraphs rather than after a fixed number of characters.

    Hadn't considered wordpress and to be honest haven't used it before either so could be a steep learning curve to implement this into my existing site structure?

    I just had a thought that I could just use a bog standard text area field in the admin area and have a form field to specify the number of paragraphs to show before the "Read more" link.

    Though this would require the ability to extract X number of paragraphs from the text in the database. Any advice on how to do this appreciated.

    Possibly something like the following would work?

    Code:
    $paragraphs = explode("\n\r", $_POST['article']);
    See any flaws in this?
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    WordPress uses the <!--more--> tag to indicate where the "read more" message should go.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Stephen

    If I was to use a tag like wordpress uses, would it be the case of me having to give instructions to the client that they need to type <!--more--> into the text area field at the point they want the article to be split? Or is there a more user friendly way to do this for those that have no knowledge of "tags"

    Thanks

    Paul
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Could you not have a nice little 'Insert Read More' JavaScript button to add this (tag) for you?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #9
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Anthony. I am not sure if I can have this such a button at the same time as using the TinyMCE editor (or similar editor) - can I? Sorry I haven't used a WYSIWYG editor before so this is all new to me
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  10. #10
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sorry, no idea. I think of these things, but have never tried them. Think, Stephen Hawking. Ha!
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  11. #11
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey no worries. I am going to try and go with the solution that has a field to specify how many paragraphs are before the read more link. Just need to get a solution to parsing the paragraphs. I have started a new thread to deal with this.
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •