trouble using {php}include(filename);{/php}

gkh01

Joined: 2007-02-22
Posts: 3
Posted: Thu, 2007-02-22 04:31

Elsewhere in the forum I saw where someone was told how to include a php file using this syntax: {php}include(filname);{/php}

On my site I have a navigation bar that is included on each *.shtml page using a SSI statement:
<!--#include virtual="../navbar2.htmlf" -->
and each *.php page using include():
<?php include("../../navbar2.htmlf"); ?>

Of course the point is to update only navbar2.htmlf when a change is needed.

In order to make G2 appear like every other page on my site, I tried to add it to public_html/gallery/themes/classic/templates/local/theme.tpl using this statement:
{php}include("/navbar2.htmlf");{/php}

But I get this error message:
Warning: main(/navbar2.htmlf) [function.main]: failed to open stream: No such file or directory in /home/hrsmsor/public_html/gallery/g2data/smarty/templates_c/%%3361524034/%%C7^C79^C790B080%%theme.tpl.php on line 50

Site is http://66.249.137.29 (domain name hrsms.org being transferred)

Thanks in advance !!!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2007-02-22 12:49

the path is probably wrong.
where's this navbar2.htmlf file? maybe at '/home/hrsmsor/public_html/navbar2.htmlf' ?

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
gkh01

Joined: 2007-02-22
Posts: 3
Posted: Fri, 2007-02-23 03:30

Yes, the navbar2.htmlf is in the public_html folder.

I thought starting with a slash would make the path relative to public_html.
I know I've used it that way with success before, but perhaps not for SSI or PHP includes. I know for sure it is working for linking-in my css file. Is this not legal for a PHP include? I'm at work and this code is at home. I'll look this evening to see if I've used it that way in the past. Even if I have, maybe it doesn't work with the smarty code (which is 100% new to me starting with last evening).

I've never seen/used a path starting with /home/... I'll try that.

Thanks.

 
gkh01

Joined: 2007-02-22
Posts: 3
Posted: Fri, 2007-02-23 14:39

Changing from
{php}include("/navbar2.htmlf");{/php}
to
{php}include("/home/hrsmsor/public_html/navbar2.htmlf");{/php}
did the trick

This works
<img src="/images/pic.jpg">
For an image stored in public_html/images

Obviously the php include command does not work the same way. Thanks for the tip.