Jump to content

php interim solutions


Glom

Recommended Posts

As I've posted previously, I'm looking to convert my website to php. Unfortunately for me, it's taking me a while to learn all the stuff around and the stuff posters have given me in order to do it properly. The idea is to use something like XML to order the website properly as I've said before and as posters have tried to help me with.I don't see much point in converting to my more basic idea of simply using variables in each page (variables which may need changing page by page if I change the way I want to do things and variables, which may relate to others pages but must be changed manually, which is what I'm trying to avoid by using server scripting) if I'm going to have to do a reconvert once I figure out how to do it right.So I thought of a crude interim solution that would avoid the problem. I use a php switch to feed in these data. The switch would basically fulfill the role of this XML or other by providing a single point from where information relating to site organisation can be found and used.The advantage of this as I see it is that the individual pages would retain the target form: content markup with php include commands above and below to past in the works. (see below for what I mean)Now, I know using a switch is pretty amateurish, but I think it would achieve the aim of allowing me to move to php now while not forcing me to do another site overhaul when I figure out how to use all the tools properly.Does anyone else think this would not work because:

  1. It will not make the pages properly?
  2. I would still have to change every page later on when I move to XML/whatever?

<!-- my current form of a php page for my site --><?php//Add many string variables such as title, description etc.  If I decided to change the way I use them/add more etc, I would have to go through each page making the change./*Also, links and titles of neighbouring pages in the sequence.  Say this was page 6 of the site.  I would have a link to page 5 and page 7 here.  Page 5 and page 7 would have string variables referring to this page.  If I decided to move this page to page 11, then I would have to change this links and titles for this page, pages 5 and 7 since they now are next to each other rather than this page, and page 10 and the former page 11, not to mention menu pages.*/?><?php include("frontend.php"); /*This will contain the working that puts in the markup that goes above the content.  Since all pages use it, by changing it, the whole website is changed in a single blow */ ?><!-- All the content markup --><?php include("backend.php"); //This will contain the workingthat puts in the markup that goes below the content ?>

<!-- the concept for the ultimate page - much simpler --><?php$serialnumber = 6; /*With this single variable, the bookend pages can access from the database all the information they need to compose the markup and with the database being standard, it makes it easier to make sitewide changes.*/?><?php include("frontend.php"); //This will contain the working that puts in the markup that goes above the content ?><!-- All the content markup --><?php include("backend.php"); //This will contain the workingthat puts in the markup that goes below the content ?>

Link to comment
Share on other sites

If I understand you correctly, you intend on having some variables about your pages stored in the database. These may include the page title, a previous and next page reference, etc. My only suggestion would be rather than storing, for example, "6" on your page, perhaps you could derive the id from the name of the file itself.You could include code on your page that checks to see what the name of the file is (by looking at the URL), and then look up your data in the database based on that information. This way, if you move pages around in your site, you won't have to worry about changing that "6" into a "10", you can simply change the values for that record in your database. Also, you wouldn't have to look at the database to decide if the next page you add to the site needs to have a number "15" or a "16" assigned to it. You just add a record to your table with the file's name as the key.I hope this makes sense. :)

Link to comment
Share on other sites

If I understand you correctly, you intend on having some variables about your pages stored in the database. These may include the page title, a previous and next page reference, etc.
You have the story exactly.
My only suggestion would be rather than storing, for example, "6" on your page, perhaps you could derive the id from the name of the file itself.You could include code on your page that checks to see what the name of the file is (by looking at the URL), and then look up your data in the database based on that information. This way, if you move pages around in your site, you won't have to worry about changing that "6" into a "10", you can simply change the values for that record in your database. Also, you wouldn't have to look at the database to decide if the next page you add to the site needs to have a number "15" or a "16" assigned to it. You just add a record to your table with the file's name as the key.I hope this makes sense. :)
Well I was probably a bit misleading (to myself as well) by using 6 as the serial number in that example. The idea is that the serial number would be a permanent attribute of the page rather than a than position specific. It is just an identifier.I am liking the idea of using the file name as the ident though. The only thing is that I need to be sure it is fully useable for various operations such as a switch. I know in C++ a switch will only accept integer cases. It cannot use strings.Is there a function that can return the file name? Or would I still have to manually load it as a variable on the page (which isn't too much hassle since it would be non-changing)?
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...