Jump to content

I need a good alternative for an include statement! Suggestions?


Recommended Posts

Hello!

 

I am in the process of building a site for which I would ordinarily use include statements to pull page content into the main template. I'm also using a switch statement that involves includes to randomly pull content into a supplementary element on each "page."

 

My problem? The person I am creating this site for has INSISTED on hosting with Yahoo! and Yahoo! places all sorts of restrictions on allowable PHP including the prohibition of include statements and disallowing the client from accessing php.ini and .htaccess files.

 

I am, of course, using CSS for 100% of the styling and I know that I could revert to separate XHTML pages for all of the content and utilize JavaScript for the random content. But with the amount of content that I need to include, the JavaScript in particular would end up being very bulky indeed.

 

Here is the code I ordinarily use to call in the page content:

 

<?php

  require_once("utils.php");

 

  $_params = getParams();

 

  /*

  $_pageName = ($_params["page"] != "" ? $_params["page"] : "home");

  $_pageName .= ".php";

  */

  $_pageName = getPage() . ".php";

?>

 

-and-

 

<div class="text">

<!-- page main content area -->

<?php include($_pageName); ?>

<!-- end page main content area -->

</div>

 

 

Here is the switch statement I was utilizing for the supplementary content:

 

<div class="feature">

<?php

//chooses a random number

$num = Rand (0,4) ;

 

//starts the random quote switch loop

switch ($num)

{

case 0:

include("features/placeholder.php");

break;

 

case 1:

include("features/placeholder2.php");

break;

 

case 2:

include("features/placeholder3.php");

break;

 

case 3:

include("features/placeholder4.php");

break;

 

case 4:

include("features/placeholder5.php");

break;

}

?>

<div class="feature_bottom"></div></div>

 

Does anyone have a suggestion for accomplishing these tasks without use of the include statement? Any assistance is much appreciated!

 

local inclusion using include(), include_once(), require(), and require_once() will still work normally.

 

Are you really sure they don't allow include/require? The above quote came directly from yahoo's information - http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-37.html

If anything they probably blocked remote includes, which is pretty sane in such an environment.

 

Come on... blocking all includes? It's like disallowing <div> tag in HTML or writing C without header files. Still possible, but who would like that?

Thanks and apologies! It's been a while since I logged into their Yahoo! site and it looks like Yahoo! updated what they allow as of October.

 

When I first uploaded a test chunk of the site around August, Yahoo! was not allowing inclusion and was recommending another statement to access a local path, but when I tested it out, none of my variations worked out. I can see that that they still don't allow access to .htaccess or php.ini files though. 

 

I just uploaded new test files to Yahoo! (same PHP as in August but with recent changes to CSS) and it appears to be working.

 

Thank you all for your help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.