jmhyer123 Posted January 10, 2007 Share Posted January 10, 2007 Just a quick question...I am working with a free script i got and modified to suit my blogging needs. I only have one problem. Does anybody know of a script/snippet to make it so my post only goes so long and then says "Read More..." and has a link to the whole post instead of just displaying the whole post on the homepage? I just need a quick snippet that works and then I can modify it to suit my needs. It just needs to make it automatically say "Read More..." and have a link to the whole article.Thanks in advance...jmhyer123 Quote Link to comment Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 There is no magical function to do this. You can use [url=http://php.net/substr]substr[/url] to truncate your topics, but you will then need to make a script to display the whole article. Then you would simply make a link to said script, passing it the articles id through the url. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 10, 2007 Share Posted January 10, 2007 [code]<?php$string = '<p>massive <a href="here">long</a> piece of <strong>text</string> that is never gonna fit<p>';$strarr = explode(' ', strip_tags($string));$max = 40;$max_words = count($strarr) > $max ? $max : count($strarr);$newstr = NULL;for ($i = 0; $i < $max_words; $i++){ $newstr .= $strarr[$i] . " ";}echo "<p>" . $newstr . "</p>";?>[/code] Quote Link to comment Share on other sites More sharing options...
jmhyer123 Posted January 10, 2007 Author Share Posted January 10, 2007 Thanks, I will try both of those options and see which works best. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.