Blog posts and news items on homepage?

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

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

By Dave - November 17, 2008

Hi Bruno,

Typically you just copy and paste multiple blocks of viewer code where you want them to appear. It looks like something isn't quite in the right place, though.

Can you attach the index-blog.php file to this post so we can see the code? Then I can take you look and give some suggestions.
Dave Edis - Senior Developer
interactivetools.com

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