Help Functionality – Opening browser window by calling function with helpid – PHP

  php

Q(Question):

Hi!

I am trying to achieve the following:

I have a number of help pages (in the format help_nn.php where nn=helpid).

I want to be able to open a particular help page by calling the function
gethelp(nn) where nn is the helpid.

The function is contained in a header file called funcs.inc that each page
loads up when it loads.

the function currently looks like this:

<?

function gethelp($helpid="1") {

$helppage="help_" . $helpid . ".php";

?>
<script language="javascript">

window.open (‘<? echo $helppage />
‘,’location=no’,’menubar=no’,’status=no’,’height=5 00′,’width=300′);

</script>

<?

}
….which obviously doesnt work. If someone (who gets what im trying to do)
could give me a shove in the right direction, it would be appreciated. Its
been a long time since I used PHP….
Cheers

EK

A(Answer):

Edward King wrote:

The function is contained in a header file called funcs.inc that each page
loads up when it loads.

the function currently looks like this:
<?
function gethelp($helpid="1") {

$helppage="help_" . $helpid . ".php";
?>
[…censored!]
<?
}

…which obviously doesnt work. If someone (who gets what im trying to do)
could give me a shove in the right direction, it would be appreciated. Its
been a long time since I used PHP….

Of course it doesn’t work. You can’t mix php and JavaScript like this.
Php is a serverside language. That means, that php es executed on the
server. JavaScript is a clientside language. That means that it is
executed by the client’s browser.
Resumed: If the page appears in the browser window and the browser is
to interprete the html/javascript/css code, the work of the php
processor on the server has finished yet.
The only way "mixing" php and javascript is to use php to create
"dynamic" javascript code.

How do you want to open the help window? In a popup? Or do you just
want to redirect to the help document?

Saludo
Paul

A(Answer):

I need the help pages to open in a new window (popup). I think I need to
give the help window a name so that clicking on multiple help links on the
main page wont open lots of help windows, but will use any existing open
help window (hope that makes sense).

I was pretty sure that I was going about it the wrong way and knew that
generating dynamic js was probably the way, but my attempts have wreaked
havoc (with hundreds of errors appearing on the mainpage).

Since I have a lot of help links to set up, I want to put the minimum of
code in the pages that reference the help system (just a function call if
possible) and with the bulk of the code in my includes.
If you can steer me in the right direction, it would be appreciated.

EK

"Paul Wellner Bou" <pa**********@united-scripts.com> wrote in message
news:c2*************@ID-205474.news.uni-berlin.de…

Edward King wrote:

The function is contained in a header file called funcs.inc that each
page loads up when it loads.

the function currently looks like this:
<?
function gethelp($helpid="1") {

$helppage="help_" . $helpid . ".php";
?>
[…censored!]
<?
}

…which obviously doesnt work. If someone (who gets what im trying to
do) could give me a shove in the right direction, it would be appreciated.
Its been a long time since I used PHP….

Of course it doesn’t work. You can’t mix php and JavaScript like this.
Php is a serverside language. That means, that php es executed on the
server. JavaScript is a clientside language. That means that it is
executed by the client’s browser.
Resumed: If the page appears in the browser window and the browser is
to interprete the html/javascript/css code, the work of the php
processor on the server has finished yet.
The only way "mixing" php and javascript is to use php to create
"dynamic" javascript code.

How do you want to open the help window? In a popup? Or do you just
want to redirect to the help document?

Saludo
Paul

A(Answer):

On 2004-03-05, Edward King wrote:

I need the help pages to open in a new window (popup). I think I need to
give the help window a name so that clicking on multiple help links on the
main page wont open lots of help windows, but will use any existing open
help window (hope that makes sense).

I was pretty sure that I was going about it the wrong way and knew that
generating dynamic js was probably the way, but my attempts have wreaked
havoc (with hundreds of errors appearing on the mainpage).

Since I have a lot of help links to set up, I want to put the minimum of
code in the pages that reference the help system (just a function call if
possible) and with the bulk of the code in my includes.
If you can steer me in the right direction, it would be appreciated.

Please try not to top post, makes it very difficult to follow the
progress of a particular thread.

Basically what you need to do is have your gethelp function return the
address of the help page and then echo that in your link.

Your function will look something like:

function gethelp($helpindex) {
$helpfile = "help_" . $helpindex . ".php";
return $helpfile;
}

and your link will be something like:

<a href='<?php echo gethelp(1); ?>’>Help!</a>


Mike Peters
mike [-AT-] ice2o [-DOT-] com
http://www.ice2o.com

A(Answer):

Mike,

yes, this is what I wanted to do, but I was including Javascript because I
want to set the size and other parameters of the new window (no location
bar, smaller window etc).

It was how to implement this that was proving the problem. Your solution
doesnt include any way of changing the help windows parameters…how would
you go about achieving this?

By the way, I wasnt aware that I was top-posting. Im using MS Outlook to
access this group (convenience) and havent been using it long to access
newsgroups. If Im doing something that contravenes the ng rules, please tell
me about it!

EK

"Mike Peters" <o0****************@THIShotmail.com> wrote in message
news:f3******************************@news.teranew s.com…

On 2004-03-05, Edward King wrote:

I need the help pages to open in a new window (popup). I think I need to
give the help window a name so that clicking on multiple help links on
the main page wont open lots of help windows, but will use any existing open
help window (hope that makes sense).

I was pretty sure that I was going about it the wrong way and knew that
generating dynamic js was probably the way, but my attempts have wreaked
havoc (with hundreds of errors appearing on the mainpage).

Since I have a lot of help links to set up, I want to put the minimum of
code in the pages that reference the help system (just a function call
if possible) and with the bulk of the code in my includes.
If you can steer me in the right direction, it would be appreciated.

Please try not to top post, makes it very difficult to follow the
progress of a particular thread.

Basically what you need to do is have your gethelp function return the
address of the help page and then echo that in your link.

Your function will look something like:

function gethelp($helpindex) {
$helpfile = "help_" . $helpindex . ".php";
return $helpfile;
}

and your link will be something like:

<a href='<?php echo gethelp(1); ?>’>Help!</a>


Mike Peters
mike [-AT-] ice2o [-DOT-] com
http://www.ice2o.com

A(Answer):

On 2004-03-06, Edward King wrote:

Mike,

yes, this is what I wanted to do, but I was including Javascript because I
want to set the size and other parameters of the new window (no location
bar, smaller window etc).

It was how to implement this that was proving the problem. Your solution
doesnt include any way of changing the help windows parameters…how would
you go about achieving this?
It’s basically the same, just echo the output from your function into
your javascript. As an example:

<Script Language="JavaScript">
function load(page) {
window.open(page,”,’menubar=no,height=600,width=8 00,resizable=yes,toolbar=no,
location=no,status=no’); }
// –>
</Script>

Your link will look like:
<a href="javascript:load(‘http://your_domain/<?php echo gethelp(1) ?>’)">Help!</a>
By the way, I wasnt aware that I was top-posting. Im using MS Outlook to
access this group (convenience) and havent been using it long to access
newsgroups. If Im doing something that contravenes the ng rules, please tell
me about it!

EK

It just makes it easier to follow what is going on if you post your
answer below what has gone before, so the whole thread reads like a
conversation eg:

Q: Why shouldn’t I top post?
A: Because it makes threads difficult to follow

as opposed to:

A: Because it makes threads difficult to follow
Q: Why shouldn’t I top post?

HTH

Mike Peters
mike [-AT-] ice2o [-DOT-] com
http://www.ice2o.com

A(Answer):

Mike,

have changed newsreader and will attempt to implement your suggestion
this evening.

Regards
Edward King

LEAVE A COMMENT