/blog/archive.php?cat=news perch_get('cat') would return 'news' because cat=news. The code below looks for different options in the URL, and then displays different types of listings based on it. */ /* --------------------------- POSTS BY CATEGORY --------------------------- */ if (perch_get('cat')) { echo '<h1>Archive of: ' . perch_blog_category(perch_get('cat'), true) . '</h1>'; perch_blog_custom(array('category' => perch_get('cat'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order)); $posts_displayed = true; } /* --------------------------- POSTS BY TAG --------------------------- */ if (perch_get('tag')) { echo '<h1>Archive of: ' . perch_blog_tag(perch_get('tag'), true) . '</h1>'; perch_blog_custom(array('tag' => perch_get('tag'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order)); $posts_displayed = true; } /* --------------------------- POSTS BY DATE RANGE --------------------------- */ if (perch_get('year')) { $year = intval(perch_get('year')); $date_from = $year . '-01-01 00:00:00'; $date_to = $year . '-12-31 23:59:59'; $title_date_format = '%Y'; // Month and Year? if (perch_get('month')) { $month = intval(perch_get('month')); $date_from = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00'; $date_to = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-31 23:59:59'; $title_date_format = '%B, %Y';
/blog/archive.php?cat=news perch_get('cat') would return 'news' because cat=news. The code below looks for different options in the URL, and then displays different types of listings based on it. */ /* --------------------------- POSTS BY CATEGORY --------------------------- */ if (perch_get('cat')) { echo '<h2 class="page-title">Archive of: ' . perch_blog_category(perch_get('cat'), true) . '</h2>'; perch_blog_custom(array('category' => perch_get('cat'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, 'paginate' => true, 'page-links' => true, 'page-link-style' => 'all')); $posts_displayed = true; } /* --------------------------- POSTS BY TAG --------------------------- */ if (perch_get('tag')) { echo '<h2 class="page-title">Archive of: ' . perch_blog_tag(perch_get('tag'), true) . '</h2>'; perch_blog_custom(array('tag' => perch_get('tag'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, 'paginate' => true, 'page-links' => true, 'page-link-style' => 'all')); $posts_displayed = true; } /* --------------------------- POSTS BY DATE RANGE --------------------------- */ if (perch_get('year')) { $year = intval(perch_get('year')); $date_from = $year . '-01-01 00:00:00'; $date_to = $year . '-12-31 23:59:59'; $title_date_format = '%Y'; // Month and Year? if (perch_get('month')) { $month = intval(perch_get('month')); $date_from = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00'; $date_to = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-31 23:59:59'; $title_date_format = '%B, %Y';