include php file?

Having trouble installing serendipity?
Post Reply
pischla
Regular
Posts: 12
Joined: Wed Oct 04, 2006 3:54 pm

include php file?

Post by pischla »

Hi!

I'm trying to include a php-file containing a text-link-menu in a table inside serendipity and it seems to break the css-styling in Internet Explorer. In Firefox it's working beautifully.

I have embedded the command

Code: Select all

include('../textlinksmenu.php');
above ob_start() in index.php.

Any hints to why Internet Explorer is troublesome?

The code in "textlinksmenu.php" is as following:

Code: Select all

<html>
<link href="../main_sitewide.css" rel="stylesheet" type="text/css">

<body>
<center><table border="0">
<tr>
    <td><div align="center"><a href="../gallery/index.php" class="Maincss">Galleri</a> | <a href="../blog/index.php" class="Maincss">Blogg</a> | <a href="../guestbook/view.php" class="Maincss">Gästbok</a> | <a href="../links.html" class="Maincss">Länkar</a> | <a href="../index.html" target="_parent" class="Maincss">Hem</a> </div></td>
  </tr>
</table>
</center>
<br clear="all" />
</body>
</html> 
regards,
pischla
pischla
Regular
Posts: 12
Joined: Wed Oct 04, 2006 3:54 pm

Re: include php file?

Post by pischla »

Now I've also tried all the suggestions about using smarty php-include tags in my index.tpl and turning of security in the only config.inc file that I've found serendipity_config.inc.php.

If I put the line about security off in config, the blog won't display at all and when I put the smarty php include tags in index tpl I don't get my menu showing up. Also tried with the smarty-markup-plugin but that messed up my codepage...

I've tried with the following:
http://board.s9y.org/viewtopic.php?f=2& ... php#p84409
and
http://www.s9y.org/78.html#A4

This code does nothing:

Code: Select all

{php}
$f = '/path/to/my/file/templates/myTemplate/textlinksmenu.php';
if (file_exists($f)) { echo 'File exists'; } else { echo 'File does not exist'; }
include $f
{/php}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: include php file?

Post by garvinhicking »

Hi!

That's pretty evil. You cannot simply include a file like this which has it's own <html>. Look inside the output of your page, it will have two <html>.

That it works in ANY browser is a wonder.

You should better put this code directly into the index.tpl file of your template. You should NEVER EVER patch PHP files from Serendipity itself.

(You can use the {include_php} smarty tag to include PHP files inside a .tpl template file. To do that, you must disable Smarty security, by editing/creating a config.inc.php file inside the template directory:

Code: Select all

<?php
$serendipity['smarty']->security = false;
Also, you need to change your .php file so that it no longer outputs any <html> stuff.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: include php file?

Post by garvinhicking »

Hi!

Oh, I didn't see your new posting.

Turning of security is not to be done inside serendipity_config.inc.php. You should create a config.inc.php file in the same directory where your index.tpl file lies in.
This code does nothing:
It will only do something once the security mode is properly disabled.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
pischla
Regular
Posts: 12
Joined: Wed Oct 04, 2006 3:54 pm

Re: include php file?

Post by pischla »

Thank you GOD of blog software... :D

I'm such a noob when it comes to php so it's mostly trial and error.
I added a config.inc.php in my mt-trendy folder which contained the security thing and put the include in the .tpl instead.

Works like a charm!
gamegarro
Posts: 1
Joined: Tue Jul 07, 2009 5:06 am

Re: include php file?

Post by gamegarro »

Thank you for your discussion. The same problem happened to me. It is very helpful to me.
Post Reply