1

Topic: Put extern.php output into variable

Hi,
I'm using a Template System, and i want to replace {$tickerlist} (in the Template) with the 10 newest Topics of the Forum. So i need to put the "<li>foobar</li>" output from the extern.php into a variable that i can assign to $tickerlist later.

I tried to replace

echo '<li><a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$subject_truncated.'</a></li>'."\n";

with

$ret .=  '<li><a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$subject_truncated.'</a></li>'."\n";

in the extern.php.

Then included the extern.php in my php file that assigns variables for the template and assigned the $ret to the tickerlist.

include 'http://localhost/pages/virtpress/forum/extern.php';
$smarty->assign('tickerlist', $ret);

(I assigned the $_GET variables directly at the beginning in the extern.php, because i must not use paramters behind the URL.)

<ul>
{$tickerlist}
</ul>

Now it puts out nothing at the page -.-
Why's that? Anyone has another idea for using extern.php with a Template System?

2 (edited by quaker 2007-07-24 17:43)

Re: Put extern.php output into variable

can u not just do a php include in the template system?

</php
include 'http://localhost/pages/virtpress/forum/extern.php';
?>

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

3

Re: Put extern.php output into variable

Actually.... yes.

But why using Template Engine when i use PHP code in it -_-?

Re: Put extern.php output into variable

You would need to fetch the file using file_get_contents, fopen, fsockopen, curl, etc: those are all options

5

Re: Put extern.php output into variable

file_get_contents and fsockopen is disabled at my webhoster

how can use fopen here?
what to do with the resource when openend the extern.php?

Re: Put extern.php output into variable

Look at the documentation for fopen, fread, and fclose. fread returns a string which is the contents of the response.