OOP help for simple CMS sites - creating reusable code

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
foobaa
Forum Commoner
Posts: 40
Joined: Tue Feb 13, 2007 10:36 am

OOP help for simple CMS sites - creating reusable code

Post 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
Last edited by foobaa on Mon Mar 12, 2007 3:21 am, edited 2 times in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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...
(#10850)
Post Reply