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
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: [bruno] Blog posts and news items on homepage?
By Dave - November 17, 2008
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.
interactivetools.com
Re: [Dave] Blog posts and news items on homepage?
By bruno - November 18, 2008
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',
));
?>
Re: [bruno] Blog posts and news items on homepage?
By bruno - November 18, 2008
Re: [bruno] Blog posts and news items on homepage?
By bruno - November 18, 2008
<?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
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!
interactivetools.com