Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

sorry guys - try this one: perl, phtml and apache - please read

by Mac (Acolyte)
on Jul 25, 2001 at 03:28 UTC ( [id://99518]=perlquestion: print w/replies, xml ) Need Help??

Mac has asked for the wisdom of the Perl Monks concerning the following question:

OK, I have an interesting predicimant:

The site I am currently working on uses phtml html files. For example (an co-incidentally my problem) we have a page called search.phtml.

Now, in my apache config, I have set up:

AddHandler cgi-script .cgi
AddType application/x-httpd-php3 .phtml
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3-source .phps


So what this does is enables apache to process includes in phtml files. Which works fine and peechy. Now, my search.phtml page looks like this:

<html>
<? include ('http://edpd02/1337/common_inc/top_section.inc'); ?>
<head>
</head>
<body>
<? include ('http://edpd02/cgi-bin/1337/search.pl'); ?>
</body>
</html>

so what that does is displays a search page (includes a navigation menu at the top of the page), and then prints the results of running the search.pl script to the page( in this case we didn't run a search, so it only displays a search box)

now that works all fine aswell.

Problem is, when we run a search, the results are processed/ printed out by result.pl. This prints a new page, WITHOUT the ability to include the navigational menu at the top!!

which is where my problem lies. I guess if you have readt this and followed, you may know the answer, else I can't to my knowledge explain it any better....

basically as a result of the search it displays the results on a new page, and prints the <? include ('http://edpd02/1337/common_inc/top_section.inc'); ?> at the top of the html page, yet doesnt actually 'include' that inc file

Any ides on how to go about rectifying this?
  • Comment on sorry guys - try this one: perl, phtml and apache - please read

Replies are listed 'Best First'.
Re: sorry guys - try this one: perl, phtml and apache - please read
by synapse0 (Pilgrim) on Jul 25, 2001 at 04:51 UTC
    This sounds like more of a php question than a perl question, but either way, there is not enough info given to make that determination or to offer any suggestions. when you submit the search, does it call search.phtml, or does it call the perl script directly? what's output by the perl script?
    sorry, there's just not enough info..
    -Syn0
      Umm no not really. I did manage a dead simple workaround thou...

      OPEN (IN, "/tmp/include.inc");
      while (<IN>){ print;}
      close IN;

      does exactly what the include tag does.
Re: sorry guys - try this one: perl, phtml and apache - please read
by RatArsed (Monk) on Jul 25, 2001 at 17:40 UTC
    Trying to use PHP inside Perl isn't going to work as you'd think, is it? I'd suggest either including the results of the script into the PHP, or getting Perl to read in the PHP header, but this will be bad if someone embeds some PHP code within it at a later date.

    --
    RatArsed

Re: sorry guys - try this one: perl, phtml and apache - please read
by little (Curate) on Jul 25, 2001 at 17:32 UTC
    Hm,
    your httpd.conf might need a line as:
    AddHandler cgi-script .pl
    also.
    Did you check your result.pl for what it produces? Does it write a new document header, eg. if it would use cgi.pm's objects.
    Then it would seem that you force your server to process a processed document.
    How does your search.pl look alike, is there a target set as an argument for the form which might force the clients browser to show the result in a new window?
    Well you might try to use apaches ability (other http servers have this as well) to process server side includes. then your code would look alike:
    <html> <!--#include virtual="/1337/common_inc/top_section.inc"--> <head> </head> <body> <!--#exec cgi="/cgi-bin/1337/search.pl"--> </body> </html>

    But I would recommend to clearly review the code of your above named perl scripts (and check what they return, simplest call them from a shell) and make sure they behave as you think they do. And you might think about uniting both scripts, or utilizing the one or the other.

    Have a nice day
    All decision is left to your taste

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://99518]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-25 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found