Page 1 of 1

OOP help for simple CMS sites - creating reusable code

Posted: Sun Mar 11, 2007 8:03 am
by foobaa
Hi,

I hope this is the right forum for this, please let me know if it's not! I'm only just starting a course in OOP so not up to par, but need some advice to get started on a project.

I'm trying to make developing of simple Content Managed sites quicker by creating a simple code base I can reuse.

I'm using Smarty, and may use PEAR or others. I will be using files and a database for persistent storage.

Example pages on the site are:

Code: Select all

/index.php - 2 column layout, content managed.
/contactus.php - 1 column layout, static
/aboutus.php - 1 column layout, content managed.
/customPage.php - variable tempalte, content managed
/news/index.php?article=my_article
They will all have a standard menu.

At this point I've done all the HTML and smarty code, and just need to send pages the following data:

Code: Select all

- $currentPage
 - $nav_pages[] = array('ref'=>'desc')
 - $html_title
 - $html_keywords
 - $html_description
 - $column1content
 - $column2content
 - $templatelayout = '1col_main' || '2col_main' etc
At this point you might want to stop reading and make your suggestion :rofl: because here comes what I've thought of doing:

I could have a Page object, containing a property for each of the variables listed above. Complications would be:
1) Sometimes not all of the page object is required - eg the Navigation. ie Just because a page has a navigation tab listing 10 pages, I don't want 10 whole pages worth of data loaded, just the 'ref' and 'desc' for each page.
2) The properties would vary depending on the template of the page. $column2content is not required for 1col_main layout.

So my question is: what objects should I have, and arranged how? Sorry for the broad question - I'm looking for tips on how to code it, in terms of OOP. Eg should I have a Navigation object linking to Page objects? What design patterns could/should I use? etc.

Thanks
Jody

Posted: Sun Mar 11, 2007 10:39 pm
by Christopher
I think you are not getting any response because the code in your post is not formatted and the questions are not clear...