Hello,
I'm pretty new at php/web design and I want to create many templates for my site to separate code and structure. I found out that if I want to customize font for a template, I could put the font code in a table and reference it in the template by doing a query.
I am interested in making these templates more customizeable (so that in the future if I want to change structures for the overall site, I can do that easily). But I am having difficulty putting php code into a table, when I do a query on the table the output is blank; however I can put html code into a table.
Maybe since I'm new I'm being inefficient but here is what I'm doing. I currently have a main template that I use that includes header.php/content.php/footer.php, but I figure that in the future I may want to change the structure. I am currently under the belief that I need to create many of these template files so that I have template file + the content that it is referencing. So if I have 20 different content pages then my template for the 20th page will be something like header.php/content20.php/footer.php (I have a form that creates these files for me). But if I want to add in a side bar in the future then my core template will need to be something like header.php/sidebar.php/content.php/footer.php and so I will have to change each 20 template files.
So my thought is if I use a table to insert the php code into my template file. So the template files will query and echo a portion of the php code and then I can customize this row in the future if I want to change the structure.
For example the template file will do this...
query templatesdb
echo templatestyle
<? php include 'content.php'; ?><br>
query templatesdb
echo templatestyle row2
which will turn into this..
<? php include 'header.php'; ?><br>
<? php include 'content.php'; ?>
<? php include 'footer.php; ?>
and if I want to in the future I can change templatestyle table to put in side bar
so it will turn into this...
<? php include 'header.php'; ?><br>
<? php include 'sidebar.php'; ?> <br>
<? php include 'content.php'; ?>
<? php include 'footer.php; ?>
If theres a more efficient method at doing this please let me know. My only other thought is that I'm using the wrong data type for the field of my table. I am currently using mediumtext.
Thanks