ibechane
08-20-2008, 03:06 AM
Hi. I'm new.
I've been making web sites for just over 10 years but in the past few years, I've been striving toward the paradigm of separation of style, structure, and content. I love that it keeps everything so organized and accessible.
So my latest project, I've been taking this concept to as far of an extreme as I can. What I want to do is create a file that contains all of the data for a particular page, which may include the title, main body text, and other section-specific text, and then have my structural skeleton call each part through a php include.
My problem is that I'm not sure how I should structure my page-data file to facilitate php insertion while keeping it as simple and readable as possible.
One way that I've done it is to code the data file as a php file and call each section with functions that dump text/HTML. This seems overly complicated and inelegant. I've also tried saving HTML code as PHP variables, but I've been running into problems with existing code having quote marks in the text or attributes, and although I could slash them out, I'd like a more elegant solution if it exists.
I've also considered using XML, but I'm not sure how easy it is to store HTML data as a single XML node and call it using php.
Ideally, I would like something to the extent of :
title: Welcome to Page A
body: This is my body with <b>HTML</b> code
sectionA: This text goes in the section A area of page A
[etc...]
i.e. all page relevant data in one file, where each section is then called to the correct location with PHP.
Does that make sense? Any thoughts are appreciated!!
Thanks in advance!
I've been making web sites for just over 10 years but in the past few years, I've been striving toward the paradigm of separation of style, structure, and content. I love that it keeps everything so organized and accessible.
So my latest project, I've been taking this concept to as far of an extreme as I can. What I want to do is create a file that contains all of the data for a particular page, which may include the title, main body text, and other section-specific text, and then have my structural skeleton call each part through a php include.
My problem is that I'm not sure how I should structure my page-data file to facilitate php insertion while keeping it as simple and readable as possible.
One way that I've done it is to code the data file as a php file and call each section with functions that dump text/HTML. This seems overly complicated and inelegant. I've also tried saving HTML code as PHP variables, but I've been running into problems with existing code having quote marks in the text or attributes, and although I could slash them out, I'd like a more elegant solution if it exists.
I've also considered using XML, but I'm not sure how easy it is to store HTML data as a single XML node and call it using php.
Ideally, I would like something to the extent of :
title: Welcome to Page A
body: This is my body with <b>HTML</b> code
sectionA: This text goes in the section A area of page A
[etc...]
i.e. all page relevant data in one file, where each section is then called to the correct location with PHP.
Does that make sense? Any thoughts are appreciated!!
Thanks in advance!