Welcome to Geeklog, Anonymous Monday, December 02 2024 @ 09:58 pm EST

Geeklog Forums

Staticpages 1.2 and PHP


Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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!).
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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
 Quote

Status: offline

andi

Forum User
Newbie
Registered: 11/02/02
Posts: 1
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
 Quote

Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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"Wink;?> </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"Wink;?> 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.
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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"Wink; 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
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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
 Quote

Status: offline

moyashi

Forum User
Junior
Registered: 10/10/02
Posts: 16
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 ... Smile
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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
 Quote

Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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/
 Quote

Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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"Wink; 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?
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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
 Quote

Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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.

 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/02
Posts: 300
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 see if that helps.

As far as the right blocks, read the comments in the code I gave earlier.

tom

 Quote

Status: offline

muskrat

Forum User
Chatty
Registered: 10/31/02
Posts: 41
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.
 Quote

All times are EST. The time is now 09:58 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content