3 different news section to show on 1 Homepage "Lastest News"

5 posts by 3 authors in: Forums > CMS Builder
Last Post: December 27, 2012   (RSS)

Hi,

There are 3 news sections on our sub menu.

Product news, Events & Tradeshows, Financials news.

But there is only 1 "Latest News" block on Homepage.

I would like to list all 3 sections last news on the "Lastest News" block on Homepage.

Is there any solution for this?

Thanks!!

-Jax H.

Hi JH,

It should be pretty easy to list the 3 groups in the "Latest News" block ...

How do you differentiate between articles that belong to the 3 news categories?

Are they in separate sections? The same section with check box or pull down fields, etc.

Could you attach your current home page code?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry

Thanks a lot for your reply.

There are 3 different news on 3 different sections.

I need to display all different news on one Homepage "Lastest News" block.

Now the problem is 

On the Homepage.  On the only one "Lastest News".    the news will look like 

Lastest News 

。2013.1.6 Event news

----------------------------------------------

 。2013.1.3 Product news

----------------------------------------------

  。 2013.1.2 Product news

----------------------------------------------

  。 2013.1.1 Event news

----------------------------------------------

I can easily to display news on different block.

but no idea to display them all together.   also.  The news can sort. 

Hope someone have the solution.

Jac

-Jax H.

Hi Jac,

Assuming the three different sections are the same with the exception of the name, you could do something like this:

=======================================

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records from 'blog'
list($blog, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => false,
));


//load records from the identical test second test section.
list($news_test, $blogMetaData) = getRecords(array(
'tableName' => 'news_test',
'loadUploads' => true,
'allowSearch' => false,
));


//Merge the two arrays from the section.
$masterArray = array_merge($blog, $news_test);
//Assuming they both have a date field, sort them by that field using there unix time stamp.
$masterArray = array_groupBy($masterArray,'date:unixtime');
//Sort the new array by the date stamp.
ksort($masterArray);

======================

In this example I've combined the two sections, and then sorted them by there date field.

The limit of this method is that you won't be able to easily sort them by another field.

An easier way to do it might be to combine the three sections into one, and have a list field to select which type of news they are, this will make sorting the news stories a lot easier.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com