Forum Moderators: coopster

Message Too Old, No Replies

CMS tutorial

         

kumarsena

9:52 am on Sep 11, 2004 (gmt 0)

10+ Year Member



hey,

jst wondering if anyone knows of any tutorials that will show the design and impl. of a simple cms. im thinking of making my own and tough i might get some ideas from such a tutorial or example.

basically i have a site with following section

articles,
photos,
web dev articles etc.,
cd reviews,
receipes,
links in categories,

what would be the best way to apprach this. mostly everything will be article based i think. photo album will have a seperate script to load and display. all i need to do is upload the pics.

just looking for sugesstions really...
i think it will be some sort of a system that is based on text files for content nad include to put it all together,

would that make some sense?

sorry if this all sounds too basic, :)

kumar

mincklerstraat

3:08 pm on Sep 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Few cms's use file systems for all their articles, I don't think it's likely that someone here will be able to shake a tutorial url out of their sleeve for this question. DB's tend to be easier for real 'content management' - but what you're doing sounds to me kind of like just using a simple templating system, and then a system for grabbing links by opening up directories in the filesystem.

I sometimes use the filesystem for sort of a 'mock up' cms to later design the real, database-backend version, so I have time to think out and change around the general datastructure, and then make the db layout the most efficient possible. But I'd guess you'll want to use a db later.

Make sure you have a very, very good working knowledge of doing stuff with arrays. Your front page can have a script that does opendir() and readdir() on a general content directory, which reads a list of directies in this directory and outputs links to this same page, but with the directory name in the parameter, and a parameter serving as a function name, like 'category'. Here you have all your categories of content like recipies and cd reviews.

Use if() to check in this main page (your index.php) if $_GET['func'] == 'category'. If not, it does the above; if yes, it takes the directory given in $_GET['name'] and, after some security checking (use preg_match, make sure it, e.g., only contains chars [a-z] to prevent directory traversal), does pretty much the same as described above, except for reading this directory in $_GET['name'] instead of the general content directory. And here you have the list of all your articles.

And if the $_GET['func'] == 'content', you use file_get_contents() to get the contents of $_GET['name'] and output it.

All of this is enclosed in echo statements outputting your header and footer.

When you get to this stage, you might want to make a sidebar which always displays the menu which is made by the index page when $_GET['func'] isn't set to anything it recognizes - you know, the links based on the contents of the main content directory. And then you'll want to get fancier, and use the database solution. You'll want custom modules and stuff. Time to check out hotscripts for rather simple CMS's then.

I've wanted for a long time to know which CMS is probably best for the php-newbie to learn about writing PHP, and CMS architecture. The old-PHP-nuke style drop-in module system has proven really popular, even though it's generated such bad PR. Not, though, a bad way of learning where to put different pieces of your code, even if it's a pretty bad source for good php syntax and other aspects of php style.

What the PHP-nuke style won't teach you is good methods of object-oriented coding for making a 'drop-in' sort of module structure, I'd be interested in hearing recommendations.

kumarsena

5:16 pm on Sep 11, 2004 (gmt 0)

10+ Year Member



hey

thanks for the long reply, it has made me understand the basics more. im not sure where the site would be going in the future and how fast but ideally it would grow of course. but this is a persoanll site and i doubt it would grow too big without changing the focus of the site. anyways, lets see if i do get you right:

i have a index page, everything is sorted in folders and subfolders as a mock up db, i use php to read folders and content and display the page and links based on those results.

it sounds like u have some experience so one more q:

for now at least, i want to keep the articles in txt files. how would i make this work. i mean i would have to use html markup in the text to deal with the styling. is there any other way of dealing wiht this? is DOM and xml somethings to consider?

again thanks for the reply
kumar

mincklerstraat

10:43 pm on Sep 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd forget about worrying about DOM or xml issues and just include the files you have in those directories - don't put the <? in front and they won't parse. Keep your HTML formatting limited to just the simple <h1>, <h2>, <h3>, <p>, <div class="content"> or whatever with a pretty css stylesheet. If you need to go fancier, make these php files (so use the <?php in the front) and set variables to the different types of content you need for each page, and let your function for outputting the content of these pages in index.php output the HTML, and output these variables at the right place inside the html - i.e. -
echo '<h1>'.$recipie_title.'</h1>;
echo '<ul>';
foreach($ingredient as $v) echo '<li>'.$v.'</li>';
echo $instructions;
etc.

Have fun with your home-baked css!

kumarsena

1:01 pm on Sep 12, 2004 (gmt 0)

10+ Year Member



he he...:)

cheers mate