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 Link to comment https://forums.phpfreaks.com/topic/33536-php-blog-function/ 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. Link to comment https://forums.phpfreaks.com/topic/33536-php-blog-function/#findComment-156989 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] Link to comment https://forums.phpfreaks.com/topic/33536-php-blog-function/#findComment-156992 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. Link to comment https://forums.phpfreaks.com/topic/33536-php-blog-function/#findComment-157008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.