[wp-hackers] How to load a sidebar/footer from non-WordPress environment

Matt Martz matt at sivel.net
Fri Apr 1 04:26:16 UTC 2011


On Thu, Mar 31, 2011 at 10:49 PM, Philip Walton <philip at philipwalton.com> wrote:
> Otto, I haven't tried that so I can't confirm, but that sounds like it would
> almost certainly cause problems. Both Yii and WordPress use htaccess rewrite
> rules, both use a custom URL structure, and I believe both use
> cookies/sessions. It just seems like that would get real messy, real fast.
>
> And what about a situation where the other pages aren't being built with
> PHP? I've had similar issues when building applications with a coworker who
> uses WebObjects (Java).
>
> Is this not something anyone here has really had to deal with? It seems to
> me like it would come up frequently.
>
>
> On 3/31/11 7:57 PM, Otto wrote:
>>
>> Make a page template and include the Yii base code in that. Then use that
>> page template on a WP page.
>>
>> -Otto
>>
>>
>> On Thu, Mar 31, 2011 at 7:51 PM, Philip
>> Walton<philip at philipwalton.com>wrote:
>>
>>> I'm building a site for a client that is primarily in WordPress but
>>> contains a donation section built with the PHP framework Yii.
>>>
>>> Visually, when a user is on the donation page(s), I'd like to still show
>>> the sidebar and footer from the main WordPress blog to maintain
>>> consistency.
>>> But, obviously, I can't simply include those php files or call
>>> get_sidebar()
>>> from another application.
>>>
>>> I know there are several ways to accomplish what I'm wanting: I could use
>>> ajax, e.g. $.load(), or create a page template and file($url), but I'm
>>> looking for a better (and faster) way. I'm wondering if other folks have
>>> encountered this issue, and what they have done.
>>>
>>> If no good solutions exist, I might just write a plugin that caches theme
>>> parts periodically or after certain updates are made.
>>>
>>> Any advice?

WordPress is heavily dependent on the rest of WordPress for page
generation.  There is no simple way to separate out functionality such
as just rendering the sidebar or just rendering the footer without
loading the rest of WordPress.

Attempting to try loading it into java would just be ridiculous.  How
would you plan on executing PHP code outside of using PHP? Trying to
load it into another PHP application may be possible, but as you point
out it has the potential to cause issues.  In the end, if you want to
use WordPress then why just not use WordPress, or write the
functionality you want from WordPress in whatever other application
you insist upon using.

I guess technically you could create pages in WordPress and assign a
page template to it, call the page sidebar and create a page template
that only displayed the sidebar and assign it to your page.  Then you
could do some sort of HTTP request to that page in WP, and inject the
HTML into your other page powered by some other app.  But that sounds
like shaving the corners off of the square peg to make it fit into the
round hole instead of just using the round peg.  At that point why not
just use WP?

-- 
Matt Martz
matt at sivel.net
http://sivel.net/


More information about the wp-hackers mailing list