Jump to content

How to do a switch to php


Glom

Recommended Posts

This is my website. It's basically like a book; a bunch of pages, divided into chapters, which can be read in a sequence, from start to finish.It's currently written in XHTML/CSS. I designed the XHTML template to give me a large degree of control through the stylesheet, but that still ultimately has limits. For a large change, such as modifying the navbar as I want to do, I would have to go through each page one by one and make the changes. Now I'm thinking about a shift over to php.The principle reasons:
  1. For a laugh.
  2. It should make changing my template easier in future.

Since the template features a bunch of mostly standard markup, then the container for the content, then more mostly standard markup, I figured that I could write a single php file for the markup above and one for the markup below and then the individual pages of the site, would basically be php files with lines of php and the top and bottom instructing an include of those book end files. This way, if I wanted to, say, update the DTD, or change the navbar layout, or anything else which is standardised, I simply adjust those standard files and the whole website is updated.The complication is that things like titles, next/previous links would be inside the book end files, despite being unique to each page. That was a fairly easy problem to solve though. For titles, keywords and the like, I simply added php string variables to the individual page and the book end files have php lines to include these variables where appropriate. This has worked in trials, though it creates a weakness in that it means these variables are a limiting factor on convenient template changes.For the next/previous links, I did something similar, though it feels sloppier. I used an array to contain the link and title of the next page.So this brings up some questions:

  • Would it be possible/sensible to create, say, an XML file that would be a database of the pages and their attributes, which would be more conveniently changeable from which the php would extract information when necessary?
  • Since I obviously have to prepare an index page with access to all pages, could this contents page be its core, like using XSL to present an XML file?
  • Would any of this result in having to resort to those funny "php?id=232" things you get because I really would rather have page addresses have a more "conventional look"? (It would look rather OTT for a site as small as mine.)

If we are talking XML, here is what it could look like:

<chapter>  <chapname>Science</chapname>  <page id="7">	<pagename>The atom</pagename>	<filename>atom</filename>	<keywords>atom, nucleus, proton, neutron, etc</keywords>	<description>A primer on the basic structure of the atom and the nucleus blah blah blah</description>	<updated><y>2006</y><m>10</m><d>30</d></updated>  </page>  <!--Then more pages etc--></chapter><!--Then more chapters etc-->

If it wanted to add a new attribute to each page, it would be easier to make edits and then upload one file rather than having to go through and upload all of them.

  • Could this be made to work with php either in the form I presented or in another form of similar intentions?
  • You may have noticed the page id. It is basically the page number could be used for the next/previous links (since this is page 7, the server would grab the url for page 8 for the next link etc). Is this at all possible?

The other complication to total controllability, is with standard practices of the content. For example, I use two types of heading in the content, which at the moment involves the simple use of h2 and h3 elements (though I am experimenting with marking the h3's with a little neutron pic). But what if I decided to jazz it up with something that would require hard coding in markup?

  • Would it make sense to use php to create these headings by functions?
  • Is this another job for XML?

My intentions are basically to develop this new system, which would in essence be "perfect", in that it would give me all the control I would ever need without having to go making the same change to thirty pages.

Link to comment
Share on other sites

Such a long essay... just say you need to page an XML file and use PHP for adjusting the stuff.this post of mine has all you need.Simply adjust recordsPerPage to 1 (unless you want to view few pages at once?), rename pagedElement to "page" and adjust totalRecords to "count(/*//*[name()=$pagedElement])". In the PaginationNavigationControl template, you could show the title of the pages instead of their position... or both. Whatever you decide.Note that this is going to requre a GET variable. The only way around this is to do a URL rewriting.By the way, I notice you're also having chapters. This might complicate things with the navigation a bit, but the above is still a very good start.

Link to comment
Share on other sites

Such a long essay... just say you need to page an XML file and use PHP for adjusting the stuff.this post of mine has all you need.Simply adjust recordsPerPage to 1 (unless you want to view few pages at once?), rename pagedElement to "page" and adjust totalRecords to "count(/*//*[name()=$pagedElement])". In the PaginationNavigationControl template, you could show the title of the pages instead of their position... or both. Whatever you decide.Note that this is going to requre a GET variable. The only way around this is to do a URL rewriting.By the way, I notice you're also having chapters. This might complicate things with the navigation a bit, but the above is still a very good start.
Well when you put it like that, it's rather obvious. :) I want to make sure I don't over-complicate this. I think I'll leave all the stuff in the content container as a fixed markup and just php in things around it. This database will help with that. It'll make it easier if I change the page attributes I want to use. But I think trying to incorporate the content into XML is just asking to be unable to see the forest through the trees.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...