SiriusB Posted October 10, 2007 Share Posted October 10, 2007 Hi there. Well first of all, hello *waves* Right, down to business. I currently have a small website here: http://smp.aeternum.co.uk At the moment it is in XHTML and is static, apart from the contact page. However, I have found since publishing the site that I make lots of changes every few days. Normally this isn't a huge problem but occassionally I add extra pages/links and because of the way I have made the site, I have to update the code on each page. While musing over the best way to manage my site I came up with a few things I would like to add, such as a comments feature for each page [or just the Troubleshooting page] and some other features. So I thought I might as well change it over to PHP and stretch my new-found PHP skills. No I come to do it, I find myself stuck as to the best way to approach it. First of all I started with splitting the header, navigation and footer into their own .xhtml files and include them when necessary in one main smp.php file. This stops repetition of code and also makes it easier to make changes. The part I am stuck with is how to store and include the content. I have considered a MySQL database, but I think I would lose all the XHTML formatting [paragraphs, headers, code etc] so instead thought of putting the content into their own .xhtml files for inclusion. So now I have one .php file called smp.php which looks, roughly, like this: include ('header.xhtml'); switch ($_GET['page']) { case "Introduction": include ('introduction.xhtml'); break; case etc etc } include ('navigation.xhtml'); include ('footer.xhtml'); Is this a good way of stucturing my site? I have tested it, and it works but this current method has caused some new issues. 1: I am not sure how to change to the keywords and description in the header.xhtml 2: My CSS relies on an id added to the <body> element. Again, I am not sure how to change this depending on the page. Both of those items are in the header.xhtml file and are included [and displayed] before the content is chosen, so it is too late to change any of the details. I know this section is just for Design and Layout but I thought I should highlight my current issues. Is there a better way of dealing with this? All help is greatly appreciated Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted October 11, 2007 Share Posted October 11, 2007 for pages who's content you change often you might want to store the actual content in the Database. from there have an editor that can change the content of the database, and update the page dynamically. It can get very in depth. Best bet is to look at a CMS, like Drupal, for some ideas. Quote Link to comment Share on other sites More sharing options...
SiriusB Posted October 11, 2007 Author Share Posted October 11, 2007 I have considered a database but MySQL can't store HTML [as far as I know] and the content of my site has all been marked up. Again, my CSS relies on this. Given the amount of content I think it would be poor practice to not mark up such a large amount of content - not least sections of text and code and headers. Is there a way of storing HTML in MySQL? Quote Link to comment Share on other sites More sharing options...
kathas Posted October 11, 2007 Share Posted October 11, 2007 as TEXT maybe ??? besides HTML is plain text.... but databases can actually store anything!!! it can store binary so it can store anything... Quote Link to comment Share on other sites More sharing options...
SiriusB Posted October 11, 2007 Author Share Posted October 11, 2007 Whenever I try to add any HTML to a database it throws up errors. Usually whenever it comes across anything such as <div id="whatever"> Quote Link to comment Share on other sites More sharing options...
jorgep Posted October 12, 2007 Share Posted October 12, 2007 Ok, I wouldn't recommend using mysql for storing html, in my opinion you would be merging data and structure/design of your site. Instead you have to analyze if you can structure your data (the varying content) and project it in a mysql table, for example: If all your content have a title, a date, and a description, you could make a mysql table that have those fields: table name -> dynamic_content fields -> id : an integer auto increment auto generated title : varchar, an string field date : datetime content : blob You will have to have then a cms (content management system), its not to hard to do for this cases since you just have to add, modify and delete the dynamic_contents you want. Quote Link to comment Share on other sites More sharing options...
jorgep Posted October 12, 2007 Share Posted October 12, 2007 About the unique id in your body, I would do it this way: My files tree: - headers.php - page1.php - page2.php - footer.php in headers.php: ... #The headers files goes from your doctype declaration to the closing head tag </head> ... #if your variable keywords is not defined, you would just define it with a general keyword <?php if(!isset($keywords)){ $keywords = "General keywords of you page"; } ?> <meta name="KEYWORDS" content="<?php echo $keywords?>" /> ... in page1.php ... #before you call your headers.php file you have to define your keywords variable: $keywords = "Key words for my page"; include("headers.php"); #You will define the id inside the same file <body id='page1'> ... About the get parameter I wouldn't do it that way... you could just point your files as page1.php or page2.php, is just an opinion... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.