Integrated LifeType blogs not truncating

Integrated LifeType blogs not truncating

Postby carbonchick on Thu Oct 06, 2011 5:37 pm

I was successfully able to integrate lifetype blogs using this code:

Code: Select all
<?php

   if (!defined( "PLOG_CLASS_PATH" )) {
        define( "PLOG_CLASS_PATH", "/path/to/your/lifetype/installation/" );
    }

   // necessary classes
   require_once( PLOG_CLASS_PATH."class/bootstrap.php" );   
   lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
   lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
   
   //
   // id of your blog, you need to know this one before starting and can easily
   // be found out in the admin interface
   //
   $blogId = 1;
   
   // Load the blog articles. This method call returns an array of Article objects
   // or an empty array if there is none
   // See http://lifetype.net/api/class_articles.php#aee20e131c51a6fdbd4f0d24e16e3c76
   $articles = new Articles();
   $blogArticles = $articles->getBlogArticles(
         $blogId,                 // our blog id
         -1,                     // date, we don't care
         10,                      // amount of posts to fetch, increase this if needed
         0,                       // category id, but we don't care
         POST_STATUS_PUBLISHED    // only the ones that are published         
                                  // this method can take more parameters but we don't need them
      );

    if( count( $blogArticles ) == 0 ) {
     print("Sorry, there are no posts to display" );
   }
   else {
      // loop through the posts and show them
      foreach( $blogArticles as $article ) {
         // See http://lifetype.net/api/class_article.php for more information regarding the Article class
         $blog = $article->getBlogInfo();
         // This returns an object of type BaseRequestGenerator
         $url = $blog->getBlogRequestGenerator();
         // This returns an object of type UserInfo
         $user = $article->getUserInfo();
         // This returns an array of ArticleCategory objects
         $categories = $article->getCategories();
         // And this returns the blog locale of type Locale
         $locale = $blog->getLocale();
         // Date when this was posted, of type Timestamp
         $date = $article->getDateObject();
?>
<p>
<a href="<?php echo $url->postPermalink($article) ?>"><?php echo $article->getTopic() ?></a><br/>
 <?php echo $article->getIntroText(); ?><br/>
 Posted by: <?php echo $user->getUsername(); ?> on the <?php echo $locale->formatDate($date); ?> | Categories:
 <?php foreach( $categories as $category ) { ?>
   <a href="<?php echo $url->categoryLink($category) ?>"><?php echo $category->getName(); ?></a>, 
 <?php } ?>
</p>
<?php
      }
   }
?>


However, the entire post displays, and I want to just show the first couple of lines. The Toggle: "More..." option works on the standard template, but I would like to have it work on the integrated site. I tried using some php strlen type code, but never got it to work without breaking things.

Any guidance is appreciated.

cc
carbonchick
 
Posts: 1
Joined: Thu Oct 06, 2011 5:26 pm
LifeType Version: 1.2.11_r711

Re: Integrated LifeType blogs not truncating

Postby martinh on Mon Oct 10, 2011 5:26 am

Hm, I can't find a mistake in the code. Are you really use "echo $article->getIntroText();"? On my sites the code work.

http://www.scilogs.de/blogs/blog/hochbegabung
http://blog.karg-stiftung.de/blogs/ext/karg/index.php
martinh
 
Posts: 175
Joined: Wed Aug 01, 2007 7:32 am
Location: Heidelberg, Germany
LifeType Version: 1.2.11


Return to Other Problems

cron