Welcome to WebmasterWorld Guest from 18.104.22.168
I am working on a system, where I have sets of templates, and a special php file that reads from a database, and parses the templates, to display data in different formats.
The templates are generally used just as an addition to a regular html page (to do things like display latest news etc.), and so are included via SSI:
This instucts the parsing code to parse the template, latest_news.html, 5 times using table 20 from the database.
This all works fine.
However, in some cases, I want to return, say, a list of categories to use in my next include. I understand I can return data from includes, if they are done locally (ala include("/htdocs/parser.php")).
So my problem boils down to 2 things, one of which I need to solve:
- I cannot pass things to a local include (can I?) - such as the source, template, number of items etc... Could I fake a QUERY_STRING environment variable? Other options?
- I cannot retrieve data from a remote include in a regular manner. Could I redirect the output from an remote include into a local variable, (returning it in a semicolon delimited nature) then parse that? (There will only ever be about 5-6 short text strings I need returned).
I know this is a lot of input all at once, and I am maybe missing something obvious, so thanks for bearing with me.
I should mention, that my data source is used for a forums system, and so I am working within certain constraints on how I can go about this.
I am aware that a local include can use local variables, so I could pass information in that manner, but the parse.php document originated from another authors code, and is a very heavy file, which would be a lot of hassle to disentangle to have work by including in then calling the functions within as I need.
joined:Apr 25, 2002
I don't really follow, but why can't you use data from a remote include? And why are the variables in the rest of the script out of scope? Normally all variables that are defined at the moment of the include are available within the include. Any variables that are defined later are unavailable.
Sorry, but I'm not sure what I'm missing in your question.
PS - I just saw that you're new. Welcome to WebmasterWorld! You might want to read the new member welcome thread to get yourself oriented.
It's a helpful resource.