Example #1
0
//part-count defined in index.php
$_GET['cat'] = $url_parts[0] !== "" ? $url_parts[0] : $GLOBALS['post_categories'][0];
//cat is first url part or the default cat
$_GET['page'] = $part_count > 1 ? (int) $url_parts[$part_count - 1] : 1;
//page is always last part of url or 1
$cat = $_GET['cat'];
$page = $_GET['page'];
try {
    $db = MongoConnection();
    $db_getter = new MongoGetter($db);
    $parsedown = new Parsedown();
    $post_views = new PostViews($parsedown);
    $post_views->lazy_load_imgs = true;
    //turn on image lazy loading, false to turn off
    $post_controller = new PostController($db_getter, $post_views);
    $mongo_results = $post_controller->getHomePagePosts($page, $cat);
    //false if no result set
} catch (MongoException $e) {
    //echo $e->getMessage();
    //Mongo error, go to 404 page
    goTo404();
    exit;
}
if ($mongo_results) {
    $template = file_get_contents($GLOBALS['template_dir'] . "/base_page.txt");
    $title = $cat . " page " . $page . " - " . $_SERVER['HTTP_HOST'];
    $desc = $_SERVER['HTTP_HOST'] . " - browse " . $cat . " page " . $page;
    $scripts = "<script src='/scripts/page_actions/main_analytics.js'></script>";
    $scripts .= $post_views->lazy_load_imgs ? "<script src='/scripts/page_actions/blog_scroll_actions.js'></script>" : "";
    $tmplt_data = array();
    $tmplt_data["title"] = $title;