javascript - What are some ways to sort and load posts into a dynamic php template -
I currently have two projects, on which I am working, is a small flash game site which Practices and understands some concepts and a blog / game Dev Ads Hybrid. My question to you is that what would be the most effective way of loading the posts, so that I can prepare a page with the specified entries on them and sort them based on those categories which will later define me. It may just be my ignorance, but it seems unable to store each file in a file because there will be enough to store there. An example of an original game "post" from the small flash game site, in fact it's a divisor for everyone, and I can add something like a tag system to sort it later.
& lt; Div class = "sports" & gt; & Lt; A href = "games / game.php? Game = somegame" & gt; & Lt; Img src = "images / somegame.png" & gt; & Lt; / A & gt; & Lt; Div id = "content" & gt; & Lt; A href = "games / game.php? Game = somegame" & gt; & Lt; Header & gt; Game name & lt; / Header & gt; & Lt; / A & gt; & Lt; P & gt; Advertise on this website & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; Place <3> files in a folder on your (local) host and run the index.
/wwwroot/post.tpl & lt; Article ID = "{$ PostId}" class = "{$ postType}" & gt; & Lt; Div class = "content" style = "width: 450px; float: left; margin-right: 20px;" & Gt; & Lt; H3 & gt; & Lt; A href = "single-post .php? Id = {$ postId}" & gt; {$ PostTitle} & lt; / A & gt; & Lt; / H3 & gt; & Lt; P & gt; {$ PostContent} & lt; / P & gt; & Lt; / Div & gt; & Lt; A href = "single-post .php? Id = {$ postId}" & gt; & Lt; Img style = "height: 150px;" Src = "{$ postPreviewImage}" & gt; & Lt; / A & gt; & Lt; / Article & gt; & Lt; Br = clear = "all" /> /wwwroot/main.tpl & lt ;! Doctype html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" /> & Lt; Title & gt; {$ PAGETITLE} & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "// code.jquery.com/jquery-latest.min.js"></script> & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; {$ PageH1} & lt; / H1> & Lt; Hour & gt; Filter: & lt; Id = "filter" & gt; Select & lt; Option id = "all" & gt; Show all posts & lt; / Options & gt; {$ FilterOptions} & lt; / Select & gt; & Lt; Hour & gt; {$ Post} & lt; Script & gt; $ () Ready (function () {$ ("# filter"). Change (function () {for (var b = $ (this). Find (": selected"). Attr ("id"), d = Document.getElementsByTagName ("Article"), c = 0; c & lt; d.length; c ++) {var a = d [c]; "all" === b || B === a.className? $ ( A). FadeIn (): B! == a.className & amp; $ (a). FadeOut ()}}}}; / lt; / body & gt; & lt; Array (array ('slug' = & gt; games ',' name '= & gt; games'), array ('slug' = 'gtc:' 'dev' '' name '=' gt; 'development') ); // Get posts from DB $ postsform = array (array ('id' = & gt; 1, 'type' = & gt; ' Ems', 'image' = & gt; 'http://openmatt.org/wp-content/ upload / 2012/12 / game-on-banner page', 'title' => one about games Post ',' content '= & gt;' This is the content of my game post. Lorem ipsum .. ', array (' id '=> 2,' type '= & gt;' dev ',' Image '= & gt;' http://gregrickaby.com/wp-content/uploads/2012/03/github-logo.png ',' title '= & gt;' A post about development ',' content '= & Gt;' This is the content of my God. Lorem ipsum .. ')); // {$ html = file_get_contents (__DIR__. '/post.tpl') for posting a post template with post data function getPostHtml ($ postData); $ Vars = array ('{$ postId}' = & gt; $ postData ['id'], '{$ postType}' = & gt; $ postData ['type'], '{$ postPreviewImage}' = & gt; ; $ PostData ['image'], '{$ postTitle}' = & gt; $ postdata ['title'], '{$ postContent}' = & gt; $ postData ['content']); Return Strat ($ html, $ vars); } // Create HTML for each post $ posts = ''; Forex Currency ($ postsFromDb $ as post) {$ posts. = GetPostHtml ($ post); } // Create HTML for Category filter $ options = ';; Foreign Currency ($ postCategoriesFromDb $ as cat) {$ option. = Sprintf ('& lt; option id = "% s" & gt;% s & lt; / option & gt;', $ cat ['slug'], $ cat ['name']); } // Get a home page template $ html = file_get_contents (__DIR__. '/main.tpl'); // template vars $ vars = array ('{$ pageTitle}' = & gt; page title ',' {$ pageH1} '=>' Hello World! ',' {$ FilterOptions} '= & gt; $ Options, '{$ Posts}' = & gt; $ terms); // output client echo string ($ html, $ vars);
Comments
Post a Comment