Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Converting the Templates to PHP? (http://www.mysidiaadoptables.com/forum/showthread.php?t=1188)

Arianna 11-29-2009 12:46 PM

Converting the Templates to PHP?
 
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 Code:

<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?

BMR777 11-29-2009 01:24 PM

RE: Converting the Templates to PHP?
 
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. :)

Arianna 11-29-2009 01:40 PM

RE: Converting the Templates to PHP?
 
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?

BMR777 11-29-2009 01:42 PM

RE: Converting the Templates to PHP?
 
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.

Arianna 11-29-2009 01:51 PM

RE: Converting the Templates to PHP?
 
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

BMR777 11-30-2009 03:01 PM

RE: Converting the Templates to PHP?
 
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. :)

Arianna 12-01-2009 12:09 AM

RE: Converting the Templates to PHP?
 
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. :)


All times are GMT -5. The time now is 10:45 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.