Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Is it possible to include PHP file in template?

Quote Reply
Is it possible to include PHP file in template?
I have similar functions in PHP file, and I want to include the produced output to the page. Is it possible? Every time I've got only code-output.
Thanks.

Quote Reply
Re: Is it possible to include PHP file in template? In reply to
Been discussed before in this forum...search for PHP in the support forums using All posts for the DATE RANGE and 200 for the HITS field in the forum search form.

Regards,

Eliot Lee
Quote Reply
Re: Is it possible to include PHP file in template? In reply to
Thanks, but I've not found any answers to my question.

I resolve the problem this way:

you need a little bit to correct PHP script so it becomes JavaScript source, place it in a directory not protected by password, and call it from template in a way like

<script language="JavaScript" src="http://someserver.com/yourscript.php"></script>

This works really cool, fast, and no head-pain.

Regards,
Eximpo

Quote Reply
Re: Is it possible to include PHP file in template? In reply to
Can't you just build the pages with a .php extension, and the PHP code to the template. If you add the

<?php

# Code in here

?>

In the template of a .php page it will be parsed. That way it is server side as well, so you don't have to worry about some people not being able to see it.

Discuss webhosting at
The Webhost Area Forums!
http://www.webhostarea.com/forums/
Quote Reply
Re: Is it possible to include PHP file in template? In reply to
Hi

At http://www.a4.no/ I have build using php extensions,with no problems at all. Just use it as you would in html (because it builds that).

<? require("/full/path/to/somefile.php"); ?>

Regards,
Are

Quote Reply
Re: Is it possible to include PHP file in template In reply to
it looks like I got this to work.

But, 1 minor irratation. How do you get this to work for page.cgi?

If you go the regular build route, just drop your <?php 55555555 ?> into the html and presto!

but there is still the page.cgi problem .... hmmm wonder if it's in the build scripts somewhere ???

Quote Reply
Re: Is it possible to include PHP file in template In reply to
page.cgi is a CGI SCRIPT. You can't use PHP in a CGI script, just like you couldn't use perl code in a php script

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: Is it possible to include PHP file in template In reply to
but a cgi script can include the output of another script can't it? so the cgi script could include the output of an "included" php script although of course you don't include it...

ASciFi.com http://www.ASciFi.com/
Help Desk http://www.Techuk.com/HelpDesk/
Quote Reply
Re: Is it possible to include PHP file in template In reply to
In theory yes, but in practice it's highly inefficent and doesn't hold up under heavy loads.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Is it possible to include PHP file in template In reply to
Hi

It depends. We setup wrote a rule in Apache to make .phtml scripts act and run as cgi, therefore in theory you can get just rename your file to .phtml instead of .cgi and it will process both cgi and php at the same file.

This is how we create user quotas etc by writing direct to the required Apache and linux based files via cgi...while at the same time including the interface designs as php.

The only thing your need do remember it to use /usr/bin/php at the top of your files and of course chmod 0755 (755) the files....but it should work, well I know it does.

Martin


Quote Reply
Re: Is it possible to include PHP file in template In reply to
Alex,

The template parser, while more limited, admittedly, can do much of what the basic php and ssi includes would do. You can increase this with the <%call::to::module::sub%>.

Depending on what the php is doing, <%...%> tags might do as well, and it's all perl.

This is something that should really be explored in depth in the new docs.

I've got some templates that are pretty complex now, and display pretty quickly -- at least as quickly as back-end process.

In fact, I have one template in the MultiUp mod, that is now doing the work of 4 (?) different ones, depending on what is passed to it, or what the template finds once stuff is passed to it. It's all pretty cool.

I'm not running this under mod_perl, but I'll bet if I was, it would be really close to php or emb_perl functionality -- maybe more, since it's a bit higher-level in calling conventions.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin