Display an article in a non blog page

Display an article in a non blog page

Postby rick9004 on Mon Sep 20, 2010 9:10 am

I am running my blog in sub-folder of my primary site. The blog system works fine. On the home page of the primary site I want to display the top 3 articles (and only the teaser section) on that home page. My site is built using Smarty templates as is the blogging software.

I looked at the sample provided for displaying an article on a separate page, but that assumes that you are on pure PHP page, which I am not. I have a Smarty template pages that compose the entire home page. Thus I have 5 sections of the home page each having a smarty TPL page. All works fine for me.

In my Smarty tpl page I have this. The blogtext2 display but the blogtext does not

{* Home page Content Row 5 Column A *}

{$blogtext} <br/>
{$blogtext2} <br/>

Now for the index page... a snippet of code

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();
$btext = $article->getTopic();
// get into smarty varible

$smarty->assign("blogtext2", "blog text here");
$smarty->assign("blogtext", $btext );
echo $btext;

Notice the last three lines. My blogtext2 text does display correctly on the page. The Echo show the teaser from the article, but because of the location in the index.php file it display at the bottom of the page.

blogtext does not show anywhere

What am I missing.. ?

Thanks for your help in advance..
Posts: 1
Joined: Mon Sep 20, 2010 8:56 am
LifeType Version: 1.2.10

Re: Display an article in a non blog page

Postby jondaley on Tue Sep 21, 2010 11:30 pm

I think you are saying that the "echo $btext" correctly prints, but when you pass in the same variable to smarty it does not?
That sounds pretty crazy. I'd put some print_r(...) statements around and try to see what is happening.

One thing you don't show in your code snippet is where the closing braces are.

I'd change your echo statement to
Code: Select all
echo "loop: '$btext'<br/>";

and see if the last time through the loop it is being erased.
Lifetype Expert
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Return to Other Problems