Orasion 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 Quote Link to comment https://forums.phpfreaks.com/topic/226362-ask-codeigniter-how-to-create-preview-post/ Share on other sites More sharing options...
mikegeorgeff 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 Quote Link to comment https://forums.phpfreaks.com/topic/226362-ask-codeigniter-how-to-create-preview-post/#findComment-1168642 Share on other sites More sharing options...
Orasion Posted February 2, 2011 Author Share Posted February 2, 2011 it works great, thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/226362-ask-codeigniter-how-to-create-preview-post/#findComment-1168664 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.