Blog posts and news items on homepage?

6 posts by 2 authors in: Forums > CMS Builder
Last Post: November 18, 2008   (RSS)

By bruno - November 17, 2008

Hello,

Newbie with this CMS here - trying to figure out how to get articles or blogs to show up on a homepage with news items in a sidebar.

http://tinymouse.biz/cmstest/index-blog.php

Ive been able to get news items on a page, and blog or articles on a page, but not together. I know there must be some simple way to do this. All I am doing is using the generated code and placing it in my pages.

Thanks!

Re: [Dave] Blog posts and news items on homepage?

By bruno - November 18, 2008

Thanks Dave,

I think im basically trying to have two lists - news and blog posts/articles show up on the same page.

Could it be that both blocks of user code need to be at the top of the document? or do i need to combine these in some day?


<?php

require_once "/nfs/c01/h04/mnt/44900/domains/tinymouse.biz/html/cmsAdmin/lib/viewer_functions.php";

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
));

?>

and this:


<?php

require_once "/nfs/c01/h04/mnt/44900/domains/tinymouse.biz/html/cmsAdmin/lib/viewer_functions.php";

list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
));

?>
Attachments:

index-blog.php 13K

Re: [bruno] Blog posts and news items on homepage?

By bruno - November 18, 2008

I think to further clarify im trying to combine a news list page and a blog list page

Re: [bruno] Blog posts and news items on homepage?

By bruno - November 18, 2008

Actually I got this to work by placing the step1 code inside of each divL

<?php

require_once "/nfs/c01/h04/mnt/44900/domains/tinymouse.biz/html/cmsAdmin/lib/viewer_functions.php";

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
));
?>

It seems that this code does not need to be at the top of the page. Is this correct?

http://tinymouse.biz/cmstest/listTest.php

Re: [bruno] Blog posts and news items on homepage?

By Dave - November 18, 2008

Hi Bruno,

Glad you got it working. No, the code doesn't need to be at the top of the page, you can have it anywhere as long as it's before the spot where you display the content that you were loading.

You can also combine it at the top like this:

<?php

require_once "/nfs/c01/h04/mnt/44900/domains/tinymouse.biz/html/cmsAdmin/lib/viewer_functions.php";

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
));

list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
));

?>


This creates two variables: $newsRecords and $blogRecords that have lists of records that you can display with a foreach loop.

The reason the index-blog.php page had error was because you didn't have a foreach loop around the part that displayed the record values.

Anytime you want to display a list of records you need to use a foreach loop that looks something like this:

<?php foreach ($newsRecords as $record): ?>
<h2><?php echo $record['title'] ?></h2>
...
<?php endforeach ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com