External PHP Includes with content pages.

General project discussion. NOT for help questions.
Post Reply
silence
New Member
New Member
Posts: 4
Joined: Sun May 17, 2009 4:22 am

External PHP Includes with content pages.

Post by silence »

I have a wordpress theme I created that contains a sidebar with a portion that the client wants to edit. I figured I could create a very basic "content" page under CMSMS with a blank template and then use php include to import it into the wordpress theme. It's mainly just going to be updating text with an image or two, nothing more.

I think the main problem is including a php file that doesnt have a proper file name. Since my page is index.php?page=blog-sidebar...

I realize its somewhat dangerous to have it setup this way, but I even tried the following code to retrieve the string query (my pagename) in my wordpress PHP (which is located at /blog/ and my CMSMS is located at the root):

$_GET['page'] = 'blog-sidebar';
include('../index.php');

What would you recommend the best way to do this would be.

I think If i could somehow make one of my pages have a URL of page.php instead of index.php?page=page it would work somewhat correctly.
Last edited by silence on Sun May 17, 2009 4:44 am, edited 1 time in total.
viebig

Re: External PHP Includes with content pages.

Post by viebig »

allow_url_fopen must be enable and your host needs to be linux

Code: Select all

include 'file.php?foo=1&bar=2';
- will look for a file on the system

Code: Select all

include 'http://www.example.com/file.php?foo=1&bar=2';
- will get a generated page

further reading:

http://br2.php.net/function.include

Code: Select all

<?php

/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */

// Won't work; file.txt wasn't handled by www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';

// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';

$foo = 1;
$bar = 2;
include 'file.txt';  // Works.
include 'file.php';  // Works.

?>

silence
New Member
New Member
Posts: 4
Joined: Sun May 17, 2009 4:22 am

Re: External PHP Includes with content pages.

Post by silence »

Thank you for the quick reply. My server is linux, where can I enable allow_url_fopen... Is it in the CMSMS config.php file?

By the way, here are the current errors I am receiving using the php include code I included above:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/p/p/r/username/html/blog/wp-content/themes/pixeled.1.9.1/pixeled/header.php:7) in /home/content/p/p/r/username/html/include.php on line 34

Fatal error: Call to a member function GetConfig() on a non-object in /home/content/p/p/r/username/html/lib/adodb.functions.php on line 7
Last edited by silence on Sun May 17, 2009 6:03 am, edited 1 time in total.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: External PHP Includes with content pages.

Post by Jeff »

Why don't you just copy the sidebar and other files into UDTs?
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: External PHP Includes with content pages.

Post by Nullig »

Why don't you just use CMSMS as the input mechanism, but use straight db lookups for pulling the data into wordpress?

Nullig
viebig

Re: External PHP Includes with content pages.

Post by viebig »

Nulling and ajprog presented better alternatives to achieve the same goal. If you can provide a link I can teach you how to do it.

Regards

G
silence
New Member
New Member
Posts: 4
Joined: Sun May 17, 2009 4:22 am

Re: External PHP Includes with content pages.

Post by silence »

The problem before was mainly with getting this file into my wordpress from CMSMS, and my host disabling allow_url_fopen wasnt helping at all....

I am going to try to have the blog use a db lookup to populate the page, instead of the multiple steps involved with includes....

I have this one page on my blog where I just want a small section of the page to come from the CMS. Is anyone familiar with using db lookups to get this done? Specifically with CMSMS.

Thanks again for all the help.
Last edited by silence on Tue May 19, 2009 9:08 pm, edited 1 time in total.
Post Reply

Return to “General Discussion”