query ( 'SELECT [when] FROM [content] '. ($entry_id ? "WHERE [when]=$entry_id " : ($filter ? "WHERE [tags] LIKE '%|$filter|%' " : '')). 'ORDER BY 1 DESC LIMIT '.($page*5).',6', database::query_single_array //no data? load the error page )) outputErrorPage ('error-404', '404', 404); //pull in the base template for the page $cache->getPage ('index', $entry_id //title: //- if a content entry is being shown, use the content title ? rssTitle ($database->query ("SELECT [title] FROM [content] WHERE [when]=$entry_id;", database::query_single)) //- otherwise, show tag filter and/or page number : ($filter . ($filter && $page ? ' ยท ' : '').($page ? 'page '.($page+1) : '')), $filter); /* --- content entries --------------------------------------------------------------------------------------------------- */ //drop the dummy 6th entry per-page (used to check if we're at the end of the recordset) $end = (count ($rows) == 6) ? (bool) array_pop ($rows) : false; //each content entry is just repeated down the page, with different contents injected in //`array_reduce` iteratively concatenates a string together of each of the content entries, no `for` loop needed //the `getCachedEntry` function is in 'code/content.php', you can see the source code for that just by typing in the url replaceTemplateTag ($cache->content, 'CONTENT', array_reduce ($rows, 'getCachedEntry')); /* --- page links -------------------------------------------------------------------------------------------------------- */ //previous page link replaceTemplateTag ($cache->content, 'PAGE_PREVIOUS', $entry_id ? '' : ( $page ? replaceTemplateTag (loadTemplate ('nav-previous'), //if on page 2, don't use "page=1", it's ugly 'HREF', '/'.($page==1 ? ($filter ? "?$filter" : '') : makeQueryString (array ("$filter" => '', 'page' => $page)) ) ) : '' )); //next page replaceTemplateTag ($cache->content, 'PAGE_NEXT', $entry_id ? '' : ( $end ? replaceTemplateTag (loadTemplate ('nav-next'), //fixme: an elegant way to not include `$filter` in the array if not present? 'HREF', '/'.makeQueryString (array ("$filter" => '', 'page' => $page+2)) ) : '' )); $cache->save (); /* ==================================================================================================== code is art === */ ?>