Home

/*

We use one view to generate the home page blocks passing an argument (the third parameter) to indicate which taxonomy channel we are pulling from. eg: Entertainment = "1", Lifestyle = "2", etc. This obviates the need for multiple view template files and reduces the css.
Note: Blogs is a special case as it is a separate vocabulary, outside the channels vocabulary so we must make it's own view for it.
See views-view--home-page-channel-summary--default.tpl.php and views-view-fields--home-page-channel-summary.tpl.php for output.

*/

//assign each view to a variable

$entertainment_block = views_embed_view('home_page_channel_summary',"default","1");
$lifestyle_block = views_embed_view('home_page_channel_summary',"default","2");
$food_block = views_embed_view('home_page_channel_summary',"default","3");
$fashion_block = views_embed_view('home_page_channel_summary',"default","4");
$beauty_block = views_embed_view('home_page_channel_summary',"default","5");
//$blogs_block = views_embed_view('home_page_blog_summary');

//invoke and assign midchannel advert block to a variable
$advert_block = module_invoke('block', 'block', 'view', 16);
$advert_block = $advert_block['content'];
//end advert

//call simple views to get the most recent posting in each channel, and use strip tags to get only the unixtime interger for sorting...

$entertainment_time = strip_tags(views_embed_view('most_recent_entertainment'));
$lifestyle_time = strip_tags(views_embed_view('most_recent_lifestyle'));
$food_time = strip_tags(views_embed_view('most_recent_food'));
$fashion_time = strip_tags(views_embed_view('most_recent_fashion'));
$beauty_time = strip_tags(views_embed_view('most_recent_beauty'));

//assign each unixtime integer as the key for it's channel specific block view as value

$front_page_sorter = array($entertainment_time=>$entertainment_block,
$lifestyle_time=>$lifestyle_block,
$food_time=>$food_block,
$fashion_time=>$fashion_block,
$beauty_time=>$beauty_block
);

//reverse sort the array based on the unixtime integer

krsort($front_page_sorter, SORT_NUMERIC);

//insert the advert into the sorted array after the first block view

array_splice($front_page_sorter, 1, 0, $advert_block);

//output the sorted channel blocks based on the most recent article in each view

foreach($front_page_sorter as $key => $val) {
print "$val";
}

//print $blogs_block;

?>