ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Dynamic includes within templates

June 21, 2007 12:18pm

Subscribe [3]
  • #1 / Jun 21, 2007 12:18pm

    Daman

    10 posts

    Hi, I am building a blog where each page on the blog should have a top and side navigation menubar. I could put the menubar code in a template and include the template within all other templates, however the problem is that I do not own the navigation menubars and they are availabe as html pages within the directory structure or through http urls like http://something/topmenu.shtml.

    Are there any solutions to include content from other html pages within a template ? I am not sure if I can create EE templates as shtml pages…If that was possible I could create all my pages as shtml’s and use dynamic includes to include the external pages.

    Would appreciate any help.

    Thanks
    -Daman

  • #2 / Jun 21, 2007 12:58pm

    Lisa Wess

    20502 posts

    You could use PHP includes for this as long as you enable PHP parsing in the template =)

  • #3 / Jun 21, 2007 1:03pm

    Sue Crocker

    26054 posts

    You can use PHP to do this.

    Something like this:

    <?php include("/path/to/filename.shtml") ?>

    Where PHP is parsed on input.

    It’s just a bit more work, but it’ll work for you.

    Does that make sense?

    You could still use an embed by making a separate template that has the php include in it.

  • #4 / Jun 21, 2007 2:32pm

    Daman

    10 posts

    Thanks Lisa/Sue…I am new to PHP so wasn’t aware of the include function.

    So…I created a blank template with just the include statement. I also set the template to allow PHP on input, however viewing the template through the browser serves a blank page. It looks like that the include statement is completely being ignored. Any ideas ?

    Thx

  • #5 / Jun 21, 2007 2:35pm

    Sue Crocker

    26054 posts

    You need to be careful of the path to the file. What does that look like?

  • #6 / Jun 21, 2007 2:42pm

    Daman

    10 posts

    I tried including html content from a url within our company firewall like below…which didn’t work.

    <?php include("http://someserver/index.shtml"); ?>

    Including html from my local machine works though

    <?php include("/localDirectory/index.shtml"); ?>
  • #7 / Jul 03, 2007 12:25pm

    Wolfram

    115 posts

    Hi everybody,

    I just tried to achieve the same. So I made an extra include page, set the preferences for this file to PHP “Yes” and “On Input”, calling it in the EE template by {embed="inludes/file"} and get these messages:

    Warning: Unknown(): URL file-access is disabled in the server configuration in /usr/www/users/......./core/core.functions.php(635) : eval()‘d code on line 1

    Warning: Unknown(http://www.xxx.de/yyy.html): failed to open stream: no suitable wrapper could be found in /usr/www/users/.../core/core.functions.php(635) : eval()‘d code on line 1

    Warning: (null)(): Failed opening ‘http://www.steuerlex.de/cnt93173/aktuell.html’ for inclusion (include_path=’.:/usr/local/lib/php/’) in /usr/www/users/..../core/core.functions.php(635) : eval()‘d code on line 1

    Any ideas for me? Thanks, Wolfram.

  • #8 / Jul 03, 2007 12:48pm

    Daman

    10 posts

    Hi, I ran into the same.

    You would need to go into your php.ini file and set the parameter allow_url_include to “On”.
    That did it for me. Make sure to restart your server.
    If you are on a hosted solution, you might need to talk to the provider to set this parameter.

    -Daman

  • #9 / Jul 03, 2007 12:53pm

    Wolfram

    115 posts

    Thank you, Daman! It´s a hosted site. I hope these people can / are willing to change it. Otherwise, it´s back to frames, I guess?
    Wolfram

  • #10 / Jul 03, 2007 1:23pm

    Lisa Wess

    20502 posts

    Thank you, Daman - just to confirm: Yes, many, many sites disable PHP includes by URL for reasons that I’m not familiar with; but it is not uncommon.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases