Lasts Articles in the Site

Lasts Articles in the Site

Postby italian_user on Sun Sep 09, 2007 10:30 am

Good morning.
I have tried to make this by myself, but without success.
Also I have searched in the forum but I have not found answer.

So, I post this new question...

Is it possible to export the "recents articles" from the LT platfom and put this in the web site?

Example:
site: http://www.lifetype.net
blogLT: http://blog.lifetype.net

I would to export the column "recents articles" from http://blog.lifetype.net/summary.php and integrate this in the site http://www.lifetype.net

Please... help me! :roll: :cry:

Maybe a plugin already exists?
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby jondaley on Mon Sep 10, 2007 12:38 pm

jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby phunkphorce on Tue Sep 11, 2007 12:27 am

You can also use the RSS feed...
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby italian_user on Wed Sep 12, 2007 2:25 am

thanks very much... I was searching with others wrong words! :oops:


I'll try that code!
Thanks more! :P :P
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby italian_user on Wed Sep 12, 2007 10:57 am

:(
I'm sorry, but the code in the link of Jondaley doesn't work..

I would to try with the rss feed like Phunkphorce told me, but I don't know what I have to do...

I opened the
"blog/templates/rss/rss20.template" file..
and I copied some part of this..

I created a new page of test...

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Firts page</title>
</head>

<body>
<?php
    if (!defined( "PLOG_CLASS_PATH" )) {
        define( "PLOG_CLASS_PATH", "/home/public/blog/");
    }

    include_once( PLOG_CLASS_PATH."class/controller/controller.class.php" );
    include_once( PLOG_CLASS_PATH."class/net/http/session/sessioninfo.class.php" );
    include_once( PLOG_CLASS_PATH."class/net/http/session/sessionmanager.class.php" );
    include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
   include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );

    // create our own action map
    $actionMap = Array( "Default" => "RssAction" );
    $controller = new Controller( $actionMap, "op" );
   
   $request = HttpVars::getRequest();
   if( isset($request["summary"])) {
      $request["op"] = "rss";
      HttpVars::setRequest( $request );
      include_once( PLOG_CLASS_PATH."summary.php" );
      die();
   }

    //
    // if there is no session object, we better create one
    //
    SessionManager::Init();
    $session = HttpVars::getSession();
    if( empty( $session["SessionInfo"] ) ) {
        $session["SessionInfo"] = new SessionInfo();
        HttpVars::setSession( $session );
    }
   
    // load the plugins, this needs to be done *before* we call the
    // Controller::process() method, as some of the plugins _might_
    // add new actions to the controller
    $pluginManager =& PluginManager::getPluginManager();
    $pluginManager->loadPlugins();   

    // and call the controller
    $controller->process( HttpVars::getRequest());
?>

<channel>
  <title>{$blog->getBlog()|escape}</title>
  <link>{$url->blogLink()}</link>
  <description>{$blog->getAbout()|escape}</description>
  <pubDate>{$locale->formatDateAsRFC822($now)}</pubDate>
  <generator>http://www.lifetype.net</generator>
  {foreach from=$posts item=post}
  <item>
   <title>{$post->getTopic()|escape}</title>
   <description>
    {$post->getText()|escape}
   </description>
   <link>{$url->postPermalink($post)}</link>
   <comments>{$url->postPermalink($post)}</comments>
   <guid>{$url->postPermalink($post)}</guid>
   {assign var="postOwner" value=$post->getUserInfo()}
   <dc:creator>{$postOwner->getUsername()|escape}</dc:creator>
   {foreach from=$post->getCategories() item=category}   
    <category>{$category->getName()|escape}</category>
   {/foreach}
   {assign var="postDate" value=$post->getDateObject()}
   <pubDate>{$locale->formatDateAsRFC822($postDate, $blog)}</pubDate>
   <source url="{$url->rssLink("rss20")}">{$blog->getBlog()|escape}</source>
   {foreach from=$post->getArticleResources() item=resource}
    {** please uncomment the line below if you'd like to server everything but images, instead of
        only audio and video **}
    {** if !$resource->isImage() **}
    {if $resource->isSound() || $resource->isVideo()}
     <enclosure type="{$resource->getMimeType()}" length="{$resource->getFileSize()}" url="{$url->resourceDownloadLink($resource)}" />
    {/if}
   {/foreach}
  </item>
  {/foreach}
 </channel>
</body>
</html>


but I have some errors like this:
Fatal error: Call to undefined function lt_include() in /home/public/blog/class/controller/controller.class.php on line 17
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby phunkphorce on Thu Sep 13, 2007 4:10 am

I think you're getting totally confused, you can't mix up PHP code with Smarty code, as you have done below so before we even get any deeper with this, do you have some knowledge of PHP development?
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby italian_user on Thu Sep 13, 2007 12:45 pm

I am not very strong in the development of php... :oops:

With the code in the post of jondaley, I have this error:

Fatal error: Call to undefined function lt_include() in /home/public/blog/class/dao/articles.class.php on line 3

Maybe (of course) I wrong some things...

Can You help me?
thanks
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby jondaley on Fri Sep 14, 2007 1:37 am

lt_include was added in 1.2 I think, and if you are copying that code from somewhere to outside of lifetype, you need to add a include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
at the top of your code.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby italian_user on Fri Sep 14, 2007 2:14 pm

jondaley wrote:lt_include was added in 1.2 I think, and if you are copying that code from somewhere to outside of lifetype, you need to add a include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
at the top of your code.


I'm so happy for your reply.
Thanks very much.

I added the code at the top of my code, but now it's this error:

Fatal error: Class 'ArticleCategories' not found in /home/public/test.php on line 14

the line 14 is this:

Code: Select all
$categories = new ArticleCategories();

(I think so)

In the log file, the same error:
[14-Sep-2007 19:08:15] PHP Fatal error: Class 'ArticleCategories' not found in /home/public/test.php on line 14



My code is:
Code: Select all
        <?php
define( "PLOG_CLASS_PATH", "/home/public/blog/" );
include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );

$categories = new ArticleCategories();
$allCategories = $categories->getBlogCategories(1);

foreach( $allCategories as $category ) {
    print("Category: " . $category->getName() . "<br/>");
    $articles = new Articles();
    $maxArticles = 5;
    $lastArticles = $articles->getBlogArticles(
        1,  // blog id, change this if your blog id is not '1' but something else
        -1, // no date limit
        $maxArticles, // only 5, as defined above!
        $category->getId(), // any category
        POST_STATUS_PUBLISHED ); // only articles with published status

// now loop through them to display whatever we need
    foreach( $lastArticles as $article ) {
        $blogInfo = $article->getBlogInfo();
        $reqGen = $blogInfo->getBlogRequestGenerator();
        print("<a href='" . $reqGen->postPermalink($article)  . "'>" .
                $article->getTopic() . "</a><br/>");
    }
}

?>


Thanks very much more..
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby jondaley on Fri Sep 14, 2007 4:15 pm

You need an lt_include(...) statement for each object that you want to create.
So, for your current error, you need:
lt_include(PLOG_CLASS_PATH."class/dao/articlecategories.class.php");

If you get any other errors, search through to figure out which thing you need to include.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby italian_user on Fri Sep 14, 2007 7:13 pm

thank you for your teacher!

now, my code is more big! 8)
I added some others include...

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TestPage</title>
</head>
<body>
     
<?php
define( "PLOG_CLASS_PATH", "/home/public/blog/" );
include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );

$categories = new ArticleCategories();
$allCategories = $categories->getBlogCategories(1);

foreach( $allCategories as $category ) {
    print("Category: " . $category->getName() . "<br/>");
    $articles = new Articles();
    $maxArticles = 5;
    $lastArticles = $articles->getBlogArticles(
        1,  // blog id, change this if your blog id is not '1' but something else
        -1, // no date limit
        $maxArticles, // only 5, as defined above!
        $category->getId(), // any category
        POST_STATUS_PUBLISHED ); // only articles with published status

// now loop through them to display whatever we need
    foreach( $lastArticles as $article ) {
        $blogInfo = $article->getBlogInfo();
        $reqGen = $blogInfo->getBlogRequestGenerator();
        print("<a href='" . $reqGen->postPermalink($article)  . "'>" .
                $article->getTopic() . "</a><br/>");
    }
}
?>
</body>
</html>


..but I have a new type of error.. (I'm so sorry...)

The page is white when I run that! :(
The error log file is empty...

If I look the source code of the page..

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TestPage</title>
</head>

<body>

...and stop....

why?
thanks very very much..
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby jondaley on Sun Sep 16, 2007 11:02 am

Check your apache error log to see what error was printed out.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby italian_user on Sun Sep 16, 2007 4:30 pm

jondaley wrote:Check your apache error log to see what error was printed out.


It's true. I wanna thank you for your kindness.

If I run the page, the page stops to load but whitout errors..
(the error file log is empty)

The source of the page loaded is
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TestPage</title>
</head>

<body>



I post here the page code that I used..
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TestPage</title>
</head>
<body>
     
<?php
define( "PLOG_CLASS_PATH", "/home/public/blog/" );
include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );

$categories = new ArticleCategories();
$allCategories = $categories->getBlogCategories(1);

foreach( $allCategories as $category ) {
    print("Category: " . $category->getName() . "<br/>");
    $articles = new Articles();
    $maxArticles = 5;
    $lastArticles = $articles->getBlogArticles(
        1,  // blog id, change this if your blog id is not '1' but something else
        -1, // no date limit
        $maxArticles, // only 5, as defined above!
        $category->getId(), // any category
        POST_STATUS_PUBLISHED ); // only articles with published status

// now loop through them to display whatever we need
    foreach( $lastArticles as $article ) {
        $blogInfo = $article->getBlogInfo();
        $reqGen = $blogInfo->getBlogRequestGenerator();
        print("<a href='" . $reqGen->postPermalink($article)  . "'>" .
                $article->getTopic() . "</a><br/>");
    }
}
?>
</body>
</html>


The page is named "first.php".

Thanks very very much for your attention.
:oops:
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Postby jondaley on Sun Sep 16, 2007 10:43 pm

What happens if you add:
Code: Select all
print "hello";
just after the <?php part?
If that works, I'd put a:
Code: Select all
print_r($allCategories);
just after where that gets set, and then a:
Code: Select all
print_r($lastArticles);

where appropriate as well.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby italian_user on Tue Sep 18, 2007 1:02 pm

jondaley wrote:What happens if you add:
Code: Select all
print "hello";
just after the <?php part?
If that works, I'd put a:
Code: Select all
print_r($allCategories);
just after where that gets set, and then a:
Code: Select all
print_r($lastArticles);

where appropriate as well.


I worked 2 days about it.. I ask help to my friend who know php language... but the code is blocked at the
Code: Select all
$allCategories = $categories->getBlogCategories(1);

row..

We put many rows like
print "hello1";
print "hello2";
print "hello3";
print "hello4";
for discover where the code stops.... and we found that the code is blocked by
Code: Select all
$allCategories = $categories->getBlogCategories(1);


Sorry for my other post about this problem.. I worked 2 days before post again...

Thansk very much
italian_user
 
Posts: 193
Joined: Mon Apr 03, 2006 1:37 pm
LifeType Version: 1.2.11

Next

Return to Requests and Suggestions

cron