Help Functionality - Opening browser window by calling function with helpid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edward King

    Help Functionality - Opening browser window by calling function with helpid

    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="javas cript">

    window.open ('<? echo $helppage />
    ','location=no' ,'menubar=no',' status=no','hei ght=500','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


  • Paul Wellner Bou

    #2
    Re: Help Functionality - Opening browser window by calling functionwith helpid

    Edward King wrote:[color=blue]
    > 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....[/color]

    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

    Comment

    • Edward King

      #3
      Re: Help Functionality - Opening browser window by calling function with helpid

      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" <paul.wellner@u nited-scripts.com> wrote in message
      news:c2arrg$1r0 oe7$1@ID-205474.news.uni-berlin.de...[color=blue]
      > Edward King wrote:[color=green]
      > > The function is contained in a header file called funcs.inc that each[/color][/color]
      page[color=blue][color=green]
      > > 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[/color][/color]
      do)[color=blue][color=green]
      > > could give me a shove in the right direction, it would be appreciated.[/color][/color]
      Its[color=blue][color=green]
      > > been a long time since I used PHP....[/color]
      >
      > 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[/color]


      Comment

      • Mike Peters

        #4
        Re: Help Functionality - Opening browser window by calling function with helpid

        On 2004-03-05, Edward King wrote:[color=blue]
        > 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.
        >[/color]
        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($helpin dex) {
        $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
        I am a DevOps and Cloud architecture consultant based in Northumberland in the UK. I provide consultancy on DevOps and private and public cloud solutions. I design and implement continous integration and continuous delivery solutions using Open Source, bespoke and commercial off the shelf software. I can also provide training and tuition for you or your team in DevOps best practices, tooling and solutions, OpenSource software, automation and cloud architecture solutions.

        Comment

        • Edward King

          #5
          Re: Help Functionality - Opening browser window by calling function with helpid

          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...ho w 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__mike__0oRE MOVE@THIShotmai l.com> wrote in message
          news:f3e7804401 29f5e32af80c4ba 1eebedf@news.te ranews.com...[color=blue]
          > On 2004-03-05, Edward King wrote:[color=green]
          > > 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[/color][/color]
          the[color=blue][color=green]
          > > 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[/color][/color]
          if[color=blue][color=green]
          > > possible) and with the bulk of the code in my includes.
          > >
          > >
          > > If you can steer me in the right direction, it would be appreciated.
          > >[/color]
          > 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($helpin dex) {
          > $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[/color]


          Comment

          • Mike Peters

            #6
            Re: Help Functionality - Opening browser window by calling function with helpid

            On 2004-03-06, Edward King wrote:[color=blue]
            > 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...ho w would
            > you go about achieving this?
            >[/color]
            It's basically the same, just echo the output from your function into
            your javascript. As an example:

            <Script Language="JavaS cript">
            function load(page) {
            window.open(pag e,'','menubar=n o,height=600,wi dth=800,resizab le=yes,toolbar= no,
            location=no,sta tus=no'); }
            // -->
            </Script>

            Your link will look like:
            <a href="javascrip t:load('http://your_domain/<?php echo gethelp(1) ?>')">Help!</a>
            [color=blue]
            > 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
            >[/color]
            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
            I am a DevOps and Cloud architecture consultant based in Northumberland in the UK. I provide consultancy on DevOps and private and public cloud solutions. I design and implement continous integration and continuous delivery solutions using Open Source, bespoke and commercial off the shelf software. I can also provide training and tuition for you or your team in DevOps best practices, tooling and solutions, OpenSource software, automation and cloud architecture solutions.

            Comment

            • Edward King

              #7
              Re: Help Functionality - Opening browser window by calling function with helpid

              Mike,

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

              Regards


              Edward King

              Comment

              Working...