[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 01-02-2004, 01:28 PM   · #1
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
Breast Cancer
aarrrrgghhhhhhhhhhhhhhhhh

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


Please register or log-in into NamePros to hide ads
adam_uk is offline   Reply With Quote
Old 01-04-2004, 03:54 PM   · #2
CreativeLogic
NamePros Regular
 
CreativeLogic's Avatar
 
Name: Ryan Amos
Trader Rating: (15)
Join Date: Sep 2003
Posts: 893
NP$: 18.00 (Donate)
CreativeLogic has a spectacular aura aboutCreativeLogic has a spectacular aura about
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.
__________________
Online Time Tracking
CreativeLogic is offline   Reply With Quote
Old 01-05-2004, 01:10 AM   · #3
PhreakShow
New Member
 
Name: Dylan Hall
Location: Pennsylvania, USA
Trader Rating: (0)
Join Date: Jan 2004
Posts: 7
NP$: 50.00 (Donate)
PhreakShow is an unknown quantity at this point
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.
PhreakShow is offline   Reply With Quote
Old 01-05-2004, 01:22 AM   · #4
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
Breast Cancer
yeh thats what i was thinking

cheers
adam_uk is offline   Reply With Quote
Old 01-05-2004, 08:19 AM   · #5
samscripts
NamePros Member
 
Name: Sam Yapp
Location: Canterbury, UK
Trader Rating: (7)
Join Date: Jul 2003
Posts: 99
NP$: 0.00 (Donate)
samscripts is on a distinguished road
Re: aarrrrgghhhhhhhhhhhhhhhhh

Quote:
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 Code:
//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
samscripts is online now   Reply With Quote
Old 01-05-2004, 11:53 AM   · #6
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
Breast Cancer
great!!

thanks il give that a try
adam_uk is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Hunting Moon Proof is in the Parking EscrowDNS
Advertise your business at NamePros
All times are GMT -7. The time now is 10:35 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0