Orasion 0 Posted February 1, 2011 Share Posted February 1, 2011 Hi all, im new member here and also new to php world. I use CI to learn. I copy paste the article from my wordpress blog and found <p><!--more--></p> tag but I dont know how to hide post after that tag to create preview post just like in wordpress, can you give me some advice to do that? really appreciate your help, thx Link to post Share on other sites
mikegeorgeff 0 Posted February 2, 2011 Share Posted February 2, 2011 first load the text helper, either auto load it or load it in the constructor in the controller. then use the following function: word_limiter($string, 10); where the 10 is the number of words that will display a sample post would look like the following in the view file <?php foreach ($posts as $p): ?> <h2><?php echo $p['title']; ?></h2> <p><?php echo word_limiter($p['body'], 25); ?></p> <?php echo anchor('blog/post/'.$p['id'], 'Read More >>>'); <?php endforeach; ?> The second to last line of code will create a link to the full blog article Link to post Share on other sites
Orasion 0 Posted February 2, 2011 Author Share Posted February 2, 2011 it works great, thanks for your help Link to post Share on other sites
Recommended Posts
Archived
This topic is now archived and is closed to further replies.