[solved] php include instead of content on static pages?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

[solved] php include instead of content on static pages?

Post by randulo »

EDIT: this was solved by making sure Smarty plugin was before Static Pages plugin and that Apply Markup was checked in Static Pages.

Hi,

I installed the php plugin and it works great. However, it doesn't have a way to add the page to the side menu of static pages. I would like to add a static page that calls a php script to generate a table from a mysql database. What is the best way to do this? The installation is a small trade site, not open to the public so security risks are minimal.

Taking another look, it appears that being able to add the php generated page to the Static Page list plugin would be fine. Any suggestions on how I could manage this? In other words, how to make the static pages list plugin show an additional link?

tia

randy
Last edited by randulo on Wed Sep 03, 2008 12:31 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Use php include instead of content on static pages?

Post by garvinhicking »

Hi!

The best way for this is:

1. Install the "Smarty Markup" plugin

2. Edit your template's config.inc.php to disable smarty security:

Code: Select all

$serendipity['smarty']->security = false;
3. Create a staticpage and embed your php with {php}...{/php} in the staticpage body.

You could also do it with smarty security, but then you'd need to create a custom smarty function that you can call.

Your way of adding a static page to the static page list plugin would work too, but it would require you to manually patch the plugin, as it needs to query each "page" not related to the event static pages inside the code on its own.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Re: Use php include instead of content on static pages?

Post by randulo »

garvinhicking wrote:Hi!
The best way for this is:
[good stuff snipped]
HTH,
Garvin
Thanks Garvin for coming through, as always, with a solution so quickly!

randy
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Re: Use php include instead of content on static pages?

Post by randulo »

garvinhicking wrote:Hi!
1. Install the "Smarty Markup" plugin
2. Edit your template's config.inc.php to disable smarty security:

Code: Select all

$serendipity['smarty']->security = false;
3. Create a staticpage and embed your php with {php}...{/php} in the staticpage body.

Garvin
OOPS!

Code: Select all

Fatal error: Call to undefined function: assign_by_ref() in /usr/local/apache_1.3.34/htdocs/cheese/serendipity/include/genpage.inc.php on line 36
happens when I do #2 above.

Serendipity 1.2.1 and PHP 4.4.2

I just updated to the latest static pages plugin, but it didn't fix the error (and overwrote my .tpl)

r
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Use php include instead of content on static pages?

Post by garvinhicking »

Hi!

This sounds as if s9y uses a local smarty version on your server that is too old. Either remove that old smarty, or upgrade it, or insert $serendipity['use_PEAR'] = false in your serendipity_config_local.inc.php - I wouldn't know why else there is an error, as assign_by_ref() is a smarty internal function for a long time already...

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Re: Use php include instead of content on static pages?

Post by randulo »

garvinhicking wrote: This sounds as if s9y uses a local smarty version on your server that is too old. Either remove that old smarty, or upgrade it, or insert $serendipity['use_PEAR'] = false in your serendipity_config_local.inc.php - I wouldn't know why else there is an error, as assign_by_ref() is a smarty internal function for a long time already...
Garvin
Hi Garvin,

Is Smarty required for s9y? I don'trecall ever installing it. I do see a file called
/plugins/serendipity_event_staticpage/smarty.inc.php

I'm totally lost. In addition, I tried: $serendipity['use_PEAR'] = false but that did not remove the error.

r
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Use php include instead of content on static pages?

Post by garvinhicking »

Hi!

Smarty is required, it usually ships with s9y inside the 'bundled-libs' directory.

So you don't have it on your server somewhere in /usr/local/lib/php or sth like it?

Did I understand you right, you get that error right on the frontpage? So you did not yet put any {php} code into any staticpage? How does your template's config.inc.php file look like right now?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Re: Use php include instead of content on static pages?

Post by randulo »

garvinhicking wrote:Hi!

Smarty is required, it usually ships with s9y inside the 'bundled-libs' directory.

So you don't have it on your server somewhere in /usr/local/lib/php or sth like it?

Did I understand you right, you get that error right on the frontpage? So you did not yet put any {php} code into any staticpage? How does your template's config.inc.php file look like right now?

Regards,
Garvin
Right now the lines you gave me are commented out, but YES the error come up BEFORE even inserting tags.

I do see Smarty in /usr/local/lib/php, it's version 2.6.12

I'll take a look at smarty.php.net to see about updates, but if you have any further suggestions, they are welcome! :)

r

btw, you were right:

Version 2.3.0 (Aug 7, 2002)
---------------------------

- added assign_by_ref() and append_by_ref() functions
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Post by randulo »

Hey Garvin,

Would it be possible to add the php plugin tot he static pages menu in the "other plugins" section? That would neatly solve my problem. What would it tak to add the php plugin to this list?

serendipity_event_downloadmanager Plugin is not available
serendipity_event_guestbook Plugin is not available
serendipity_event_forum Plugin is not available
serendipity_event_contactform Plugin is installed
serendipity_event_thumbnails Plugin is not available
serendipity_event_usergallery Plugin is not available
serendipity_event_faq Plugin is not available

randy
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Phew, I never had a look on how the static page plugin list outputted that, I cannot tell you what to do exactly.

The PHP plugin is harder to add to that list, because currently this list only uses plugins that only occur once, but the PHP plugin can occur multiuple times...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Post by randulo »

garvinhicking wrote: The PHP plugin is harder to add to that list, because currently this list only uses plugins that only occur once, but the PHP plugin can occur multiuple times...
Indeed, like the HTML blocks, it can occur multiple times. I hate hacking up the install because then I never want to update it. It unfortunately looks like to get what I need, I will have to screw up the static pages menu.

By the way, I noticed there were plenty of calls to the aforementioned Smarty by_ref function elsewhere and they don't error out, so the error message itself must be wrong.
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Post by randulo »

Garvin,

I see I can modify the $serendipity['smarty']->security = false; in functions_smarty.inc.php without an error. But now the

Code: Select all

{php}
tags work in normal posts but still not in static pages. (Yes, I checked the box on the plugin config page)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

What happens on a staticpage, how does the resulting HTML look like, does it still have {php} in it?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
randulo
Regular
Posts: 141
Joined: Thu Jul 21, 2005 10:28 am

Post by randulo »

garvinhicking wrote:Hi!

What happens on a staticpage, how does the resulting HTML look like, does it still have {php} in it?

Regards,
Garvin
In a word... yes. Would the order of plugins matter?

Actually, I totally have hacked a few files now and have what I want but I'd rather find a more elegant and subtle solution.

r
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

If you still see {php} then something fishy is going on in your installation, maybe the smarty markup plugin does not even get executed. I'd need to have a look at that installation via FTP or something similar, because I can'T reproduce it here.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply