Hello everybody,

So this week I am coming up with two questions, they are probably silly questions but I have googled and come up with nothing.

1)Figured out number 1 by myself, accidently had a / where it wasn't supposed to be.

2)This one I have not tried to hard to do but I want to confirm that I am going about it in the right way. What I am trying to do is have mySQL call the directory in which to look for an index.php file.

So for starters what I was going to do is make a define() string that went something along the lines of

define([template],call from mySQL database)

then use

require_once(require_once("dir/themes/[template]/index.php");

My theory is that if you were to have the directory name setup in the mySQL database it would the define function would establish that [template] was the value in the mySQL database and would then insert that name within the require_once function.

Is my theory valid or am I completely out to lunch?


Thanks for the help guys and gals!

Member Avatar for diafol

Loads of ways to do this.

Personally I'd have a 'themes' (or 'templates') table with things like:

template_id
template_name
template_dir
template_active
template_snapshot
template_author
template_date_mod

etc.

Your define (CONSTANT) needs to get this data from the DB. OK.
I bet somebody will correct me here, but to me constants are just that, constants. They should not be able to hold more than one possible value. E.g. Pi, bit

You could similarly use a variable for this. Perhaps a variable would be better if a template can be changed? You get the data from the DB as a var - so I expect this gets stored in a var, not a constant.

Anyway. If it works...

I'd have a test though to see if it works with file_exists(). If not use the default template.

Thank you for your response,

I ended up just playing with my method until it worked. What I plan to do later is have a selection page that shows all the folders containing templates so for example you would have

Templates
\/
template1 / template 2 / template 3

When you go to this page it will show templates 1-3, by selecting one it will save to the template row in the database and that is the row that currently is being read to complete my require_once() string. If this makes sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.