$paginator->total = sizeof($all_items); $paginator->pagination_root = 'category/' . $path[1] . '/'; $stub = "category_page.php"; break; case "feed": // category RSS $stub = "category_rss.php"; break; default: // if this is numeric, setup pagination and return appropriate page if (is_numeric($path[2])) { $page = $path[2] - 1; $show_prev_next = false; require EATSTATIC_ROOT . '/eatStaticBlog.class.php'; require EATSTATIC_ROOT . '/eatStaticTag.class.php'; $tag = new eatStaticTag(); $tag->file_name = $slug . '.json'; // TODO: security validation of slug $tag->loadFromFileName(); $page_title = BLOG_TITLE . ' :: ' . $tag->name; $all_items = array_reverse($tag->items); $items = array_slice($all_items, POSTS_PER_PAGE * $page, POSTS_PER_PAGE); $paginator = new eatStaticPaginator(); $paginator->current = $path[2]; $paginator->total = sizeof($all_items); $paginator->pagination_root = 'category/' . $path[1] . '/'; $stub = "category_page.php"; } break; } break;
public function deleteAll() { $tags = eatStaticTag::getAll(); foreach ($tags as $tag) { $tag->delete(); } }
<?php /** * @desc - go through live posts and create an index of tags */ require '../eatStatic_config.php'; require_once EATSTATIC_ROOT . "/eatStaticBlog.class.php"; require_once EATSTATIC_ROOT . "/eatStaticTag.class.php"; $blog = new eatStaticBlog(); $blog->getPostFiles(); print_r($blog); // delete tag cache files eatStaticTag::deleteAll(); foreach ($blog->post_files as $post_file) { $post = new eatStaticBlogPost(); $post->data_file_path = $post_file; $post->hydrate(); echo $post->title; //print_r($post->tags); foreach ($post->tags as $tag) { // create tag object -> open existing or create new $tag_object = new eatStaticTag(); $tag_object->name = $tag; // load existing items if there are any $tag_object->load(); // add data file path to tag items array $tag_object->addItem($post->data_file_path); // save tag json $tag_object->save(); } }
<?php require EATSTATIC_ROOT . '/eatStaticTag.class.php'; $tags = eatStaticTag::getAll(); eatStatic::template('page_top.php'); eatStatic::template('body_top.php'); ?> <ul class="category-list"> <?php foreach ($tags as $tag) { ?> <li><a href="<?php echo SITE_ROOT; ?> category/<?php echo $tag->getSlug(); ?> "><?php echo $tag->name; ?> </a></li> <?php } ?> </ul> <?php eatStatic::template('body_bottom.php'); eatStatic::template('page_bottom.php');