Page 1 of 1

include php file?

Posted: Sat May 23, 2009 10:27 pm
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

Re: include php file?

Posted: Mon May 25, 2009 9:34 am
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}

Re: include php file?

Posted: Mon May 25, 2009 10:24 am
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.

Re: include php file?

Posted: Mon May 25, 2009 10:26 am
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

Re: include php file?

Posted: Mon May 25, 2009 11:37 am
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!

Re: include php file?

Posted: Tue Jul 07, 2009 5:08 am
by gamegarro
Thank you for your discussion. The same problem happened to me. It is very helpful to me.