Converting the Templates to PHP?

Forum
Last Post
Threads / Messages

Arianna

Dev Staff
Staff member
Dev Staff
Joined
Sep 25, 2009
Messages
334
Points
0
Age
27
Mysidian Dollar
13,840
I want to convert my templates to PHP, for a feature that I'm making. You see, the theme url is 'blue.php', and it has a few things which are PHP in it.
What, you ask? Well, this is the code in between the head tags:
PHP:
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>:BROWSERTITLE:</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<?php
$sql = "SELECT * FROM ".$prefix."users WHERE username='".$loggedinname."'";
$result = mysql_query($sql);        
$myrow = mysql_fetch_array($result);
$stylesheet = $myrow['style'];
?>
<link rel="stylesheet" media="screen" type="text/css" href="templates/blue/default.css" title="default" />
</head>
I have this working on another site of mine, but the system doesn't seem to be able to read the actual php file - the css link is shown as:
Code:
templates/blue/blue.php<?php echo $stylesheet ?>.css
This is instead of it echoing the variable. What am I doing wrong?
 
You won't be able to run PHP from the .html template file. The system doesn't work like that. What you can try is make a new template variable, such as :MYCODE: and place that in the template. Then in the adoptables script you do your queries and then use the template system to parse the final result into :MYCODE: so it appears in the template. :)
 
Hmm, however I had it as a PHP file - does this mean that you can't use PHP files as templates? :/
And I'm also assuming that I'd need to put the replacement thing on every php page, right?
 
I don't think you can use PHP files as templates, however you may be able to use the eval() function with your code to make it execute from a PHP file template. It would be worth looking into, but I doubt it would work.

To use my method then yes, you would have to put it on every page.
 
Okay - I might start that, then, next weekend. It might be some work, but I think that it would be worth it. Is there any way that I could have it as a function or something - say that I changed the theme location - the css thing would change, and I'd need to change all of the files - again. xP Do you get what I mean? xD
 
Yeah, I see what you mean and that is something I am working on as well. :)

I'll let you know if I get it working. :)
 
I finished the whole system yesterday! Apart from the fact that my FTP program thought it would be funny if it scrambled and squished together the last lines in some files (I still can't find out why), it works. I'll post a tutorial, either here or in the donators forum, to show how to do it. :)
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,124
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top