Posted on: 11/01/02 12:38pm
By: muskrat
I downloaded staticpages 1.2 because I want to be able include PHP code in a static page. Then I read the README file, which has a pretty stern warning about how much you can screw up GL by using this feature. Hmmm... since I don't know much about GL and don't want to screw up my install, I'm proceeding with caution! So I'm not installing 1.2 until I find out if it will even work for what I want.
Here's what I want:There's an open source package called phpESP (easy survey package). It allows creating a survey which can be pretty complex, and then gives you a line of php to include in some other php page. This lets you style the page as you want, and phpESP handles the mechanics of all the check boxes, radio buttons and so on inside the survey.
I would like to put this in a staticpage. it would give me much more elaborate capabilities than the current "poll" mechanism.
Is this the sort of PHP that can be put into a static page? Or is it just intended that the php in a staticpage would call gl's internal php routines (which I have no need for at this time, as far as I know!).
Staticpages 1.2 and PHP
Posted on: 11/01/02 05:47pm
By: tomw
The sort of php that can be put in a Staticpage php page is some that will return formated html. If the line of php that you will be inserting returns html and does not do its own display it will work just fine. For the php to work in a static page you must end the static page with a return that returns the html that you want displayed.
If the line of php you are going to enter handles its own display then you will need to wrap Geeklog around your code like this:
<?php
require_once('lib-common.php');
echo COM_siteHeader('none'); // use 'menu' if you want the left blocks
?>
// Put your html or mixed html/php code here
<?php
echo COM_siteFooter(no); // use yes if you want the right blocks
echo $display;
?>
Does that make it clear as mud?
Tom
Staticpages 1.2 and PHP
Posted on: 11/02/02 04:31am
By: andi
Hi, i just wondering is that any way that we only can open the pages only by selected user/group, it would be great for security reason if you have a file or contents that only can open by selected user/group.
Thanks
Andi
Staticpages 1.2 and PHP
Posted on: 11/02/02 06:33am
By: muskrat
A little muddy, yes. I don't know what you mean by "does
its own display." Doesn't PHP always produce HTML for
the browser, which does the display?
Do you mean "creates a whole page or just the body?"
The php include tests that I've done with this package
are interesting. If I create a page with html for head and
body -- a properly formed "shell" page with just a title --
and then I insert the php include statement that the
survey package recommends within the body like this:
<BODY>
<?php $sid=3;
include("/usr/local/lib/php/contrib/phpESP/public/handle
r.php"
;?>
</BODY>
then save the page with .php extension to my server
and browse to it, the page works fine. The survey is
functional. If I then "view source", the page is what I
would expect. The HTML is reasonable and the survey
package did its work by nserting html within the BODY
of the page only.
If I create a totally empty file, put this in it:
<?php $sid=3;
include("/usr/local/lib/php/contrib/phpESP/public/handle
r.php"
;?>
and save it with a php extenstion, browse to, it also
works. However, now when I view the source, I see that
the necessary <HTML> and <HEAD> and <BODY> tags
have been inserted by some magic.
So, do you consider this php to be "doing its own
display" or not, and more to the point, is there any
reason to think that this would need the sort of
"wrapper" of a gl function that you described, or not?
Thanks.
Staticpages 1.2 and PHP
Posted on: 11/02/02 07:10am
By: tomw
Yes this php is doing its own display. To start with it is a mixture of html and php. You could modify it so that it was pure php so that it would work in a static page but it would not be worth the effort. Here is what you need:
<?php
require_once('lib-common.php');
echo COM_siteHeader('none'); // use 'menu' if you want the left blocks
include("/usr/local/lib/php/contrib/phpESP/public/handler.php"
;
echo COM_siteFooter(no); // use yes if you want the right blocks
echo $display;
?>
It is like the first example that you gave but instead of a generic header/body you are enclosing it in the Geeklog header/body.
Or if you want just add the Geeklog include - siteHeader - sitefooter statments to your original page.
Try it, you will like it and amaze your friends.
Tom
Staticpages 1.2 and PHP
Posted on: 11/02/02 07:13am
By: tomw
Sure just like everything else in Geeklog (almost) you can choose who can see what. Look at the little block with the security settings on the static page editor.
Tom
Staticpages 1.2 and PHP
Posted on: 11/02/02 08:32am
By: moyashi
Can I do this in static pages?
<img src="<?php echo $main_directory ?>/map.gif">
or
<img src="[site_url}/images/site/map.gif">
where main_directory = http://www.foobar.com/images/geeked/site/
haha, I'm not sure which is longer to type anymore when I think about it.
I'm using a require_once which has the variable declared there ...
I wouldn't mind the {site_url} solution either.
I'm developing on my iBook and plan to transfer the site later and would hate to have to go through all my static pages.
lazyness ...
Staticpages 1.2 and PHP
Posted on: 11/02/02 09:44am
By: tomw
Not the way that you have it coded here. Static pages 1.2 can be either pure html or pure php but not a mixture. Variable substitution does not work either. Use a new page as I suggested earlier thus:
<?php
require_once('lib-common.php');
echo COM_siteHeader('none'); // use 'menu' if you want the left blocks
echo "<img src=\"{$_CONF['site_url']}/images/site/map.gif\"> ";
echo COM_siteFooter(no); // use yes if you want the right blocks
echo $display;
?>
Clear as mud?
Tom
Staticpages 1.2 and PHP
Posted on: 11/02/02 09:23pm
By: muskrat
doesn't work for me yet. I tried it as you wrote, and get this error:
Parse error: parse error in /Library/WebServer/Documents/
staticpages/index.php(114) : eval()'d code on line 1
I get that even if the only php code on the page is <? php ?>
Ideas/
Staticpages 1.2 and PHP
Posted on: 11/03/02 04:23am
By: muskrat
To be more specific: I copied your code and tried it in a static page.
No joy. Tried different variations on both the code and the block
settings but always got the same result.
Now, if I put this in a file called "test.php" and browse to "test.php" I
get a gl page with my survey on it (only problem is I can't get it to
stop putting the right blocks on the page, no matter what)
<?php
require_once('lib-common.php');
echo COM_siteHeader('menu'); // use 'menu' if you want the left
blocks
// Put your html or mixed html/php code here
$sid=3; include("/usr/local/lib/php/contrib/phpESP/public/
handler.php"
;
echo COM_siteFooter(no); // use yes if you want the right blocks
echo $display;
?>
but, if that same text (above) is in a staticpage, it barfs when
parsing the php, like this:
Parse error: parse error in /Library/WebServer/Documents/
staticpages/index.php(114) : eval()'d code on line 1
Suggestions?
Staticpages 1.2 and PHP
Posted on: 11/03/02 05:46am
By: tomw
Yeah, I said if you code handles its own output or it is mixed html and php put it in a page by itself -- I guess I should have added -- NOT a static page. Put that code in a file by itself name it whatever.php and it will work. The php in static pages has some strict requirements.
Tom
Staticpages 1.2 and PHP
Posted on: 11/03/02 11:30am
By: muskrat
O.k., I get it. A page all by itself
does work.
But what about that pesky row of right side boxes? Can't get rid of
it.
Also, are there any written-down guidelines as to what the
limitations are for PHP within a static page?
Thanks for you help.
Staticpages 1.2 and PHP
Posted on: 11/03/02 11:41am
By: tomw
Glad to help -- next time I am refering people to you. Just kidding but that is the way we all can help promote Geeklog and take the burden off the developers. Let the developers develop and let the users support each other.
I have written a little article about this on my website The Pigstye[*1] see if that helps.
As far as the right blocks, read the comments in the code I gave earlier.
tom
Staticpages 1.2 and PHP
Posted on: 11/03/02 11:48am
By: muskrat
O.k., I read the code in lib-common.php and now know that I need
to use
COM_sitefooter();
or
COM_sitefooter(false);
to turn off the right side blocks. putitng a string in there, like 'false'
evaluates to non-zero, which is the same as true.