![]() |
||||
|
||||
|
« Multipart Articles on GIDNetwork | Introducing GIDZipTest... again » |
Multipart Articles on GIDNetwork, Part 2
by: admin - Jan 06, 2006
After creating the database table for the multipart articles, I had to create one custom PHP function that queries the table every time an article page is viewed. Here at GIDNetwork.com, the article pages have filenames like b-84.html. Don't let that confuse you, it's not really a HTML document, it's just Apache's mod_rewrite module in action. The actual document is simply a PHP script, e.g. article.php and Apache translates b-84.html into article.php?id=84. Anyway, back to the custom PHP function... Custom PHP Function: loadArticlePartsThe custom PHP function to load the multipart article information is shown below. PHP Code Example:
Using a self-join, the SQL in this function finds the articleid off AP (an alias for the article_parts table) and then searches a copy of itself, i.e. AP2 (the alias for the copy of article_parts) for the ALL the partids matching the (found) articleid. The final (left) join is simply to get the titles off the articles table. I hope that made sense, if not, please leave a comment with your question and I will be happy to try again. Modify article.phpNow comes the part where I had to modify the article.php file. Assuming I put the loadArticleParts() function into an (existing) include file - say, functions.articles.inc.php - all I need to do is insert a few lines to show the multipart links (on the web page), if any exists for an article... PHP Code Example:
This is a 2 part article, so the results from this modification is present on this page. :P
|
GIDNetwork Sites
Archives
Recent GIDBlog Posts
Recent GIDForums Posts
Contact Us
|
« Multipart Articles on GIDNetwork | Introducing GIDZipTest... again » |