Dynadot โ€” .com Transfer

Aarrrrgghhhhhhhhhhhhhhhhh

SpaceshipSpaceship
Watch

adam_uk

Established Member
Impact
20
sup guys

anyone able to help me

im tryin to prog my own template system for somin im buildin using eregi_replace

ive managed to get it to do that but ive got a swtich statement (index.php?q=admin for example)

now what i need it to do is when admin is called is called scroll through the swtich to find the case admin load admin parse the code inside it and then echo it when eregi replace comes acrooss {content}

ive tried using fopen and fread but they dont parse the php include works ok but because its including the data before its echoing it its placing it in the wrong place

arrrrghhhhh i need some ideas how i can do this

1. get q from the url (dont this bit)
2. include the file assosiated with contents of q (array or switch) kina done this
3. parse the php inside the file
4. echo it when needed

ive managed to get number 2 to work by making an array but its using include but that goes wrong as i explained

any suggestions will be greatfull

cheers
adam
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
You basically have to code it in the way to have it include the files where you want it to be outputed. I really doubt there is any other way that would be smart doing it. You could use output buffer stuff, but I wouldn't recommend it.
 
0
•••
Sounds to me like your trying to go about this a harder way then you need to. Rethink you're template system and I think it will be easier.
 
0
•••
yeh thats what i was thinking

cheers
 
0
•••
Re: aarrrrgghhhhhhhhhhhhhhhhh

Originally posted by adam_uk

1. get q from the url (dont this bit)
2. include the file assosiated with contents of q (array or switch) kina done this
3. parse the php inside the file
4. echo it when needed


Hi, the simplest way to do this without rewriting all your code is to use output buffering:

PHP:
//1. get q from the url

$q = $_REQUEST['q'];

//2. use an array or switch statement to get the filename to include

//a) for this example, here's an array
$files = array('home'=>'index.inc.php', 'about'=>'about.inc.php', 'contact'=>'contact.inc.php');

//b) check that $q is valid, and set it to a default if not:
if( !isset($files[$q]) ) $q = 'home';

//c) get the file to include

$include_me = $files[$q];

//3. Start output buffering

ob_start();

//4. include the file associated with the contents of q
// => php in file is automatically parsed when you include it

include($include_me);

//5. Get the contents of the output buffer

$content = ob_get_contents();

//6. erase the content of the output buffer (so it doesn't get output to the browser)

ob_end_clean();

//7. do whatever else you need to do...

//8. use str_replace, ereg_replace or preg_replace to replace {content} in your template with whatever is now in the $content variable

//9. echo the output when you want it.

Hope that helps,

Sam
 
0
•••
great!!

thanks il give that a try
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back