PDA

View Full Version : Loading a template


owner
09-20-2007, 12:52 PM
Hello,

I am trying to load a template with html code and then the data is just inserted from the database.

Example:

$function .= "<tr>
<td class=\"darkrow1\" colspan=\"8\"><b>{$this->ipsclass->lang['announce_start']}</b></td>
</tr>

See how stuff is inserted like this ({$this->ipsclass->lang['announce_start']})

How do you do this? I am a bit confused on this. Is their a tutorial somewhere to get the basics down of this?

Thank you,
-Owner

davidj
09-20-2007, 01:52 PM
its produced using a CLASS (OOP)

you need to study functions and then look at php OOP

http://www.codewalkers.com/c/a/Programming-Basics/Beginning-Object-Oriented-Programming-in-PHP/

owner
09-20-2007, 09:53 PM
Davidj, I get what OOP is, and I get how the class and the function works. I am just new to it. I get the basics of OOP.

I don't want to be mean, but for some reason it seems like you think that I don't get 1 general thing about it. :(

owner
09-20-2007, 11:51 PM
Ok, I am super close.

I have a test.php file


Then inside I have

<?php
function test($links="") { //My function with the argument
$HTML = ""; //Get rid of any data if any stored in here
//Yay, html time below!
$HTML .= "<table width=\"25%\" border=\"1\">
<tr>
<td>{$links}</td>
</tr>
</table>";
//end of html
return $HTML; //Send the html with the variable inserted
}
?>Now, what should happen is when this script is initialized, my variable $test should fill in what value it has in the table. My question is, how could I call this in my function without using include (''); The reason I don't want to use include is I will have a ton of little sections like this, and I want them all to be loaded, so what would be the best way to load these up?

Summery: I just need to know howto load this file that I have here in my function. I can do the everything else, but I just don't know where to start to actually grab the info out of this file.

Thank you
-Owner

davidj
09-21-2007, 05:41 AM
I don't want to be mean, but for some reason it seems like you think that I don't get 1 general thing about it.

48 hours ago you knew nothing about OOP PHP and had the same understanding of Functions. You told me this through messenger and you requested me to help teach you on a one to one basis. I just took this evidence and concluded you knew nothing about OOP!

if the function is in a separate file you have to include it. How else would you get the function into your script.

this bit i don't understand...
$HTML = ""; //Get rid of any data if any stored in here
//Yay, html time below!
$HTML .= "<table width=\"25%\" border=\"1\">
<tr>
<td>{$links}</td>
</tr>
</table>";

writing vars like this..


$HTML ="";
$HTML .=""stuff;


all this does is concatenate the contents of $HTML so the first one contains nothing so your function is going to join nothing to the table string.

owner
09-21-2007, 10:37 PM
Just never mind this. I am going to give up on this idea. I think I have 2 or 3 topics now and noone seems to understand, so apparently it isn't possible :S

Sorry about this

davidj
09-22-2007, 06:59 PM
your probably right...

its not possible

davidj
09-22-2007, 06:59 PM
dont appologise

your probably right...

its not possible