Php includes not previewed ?

  • Advertisement ( why? )
     

    IvoAelberts, 10th Aug 2012 2:30 am

    Hi Chami,

    When I edit a .php file containing for example an artice of my website, the php include files are not taken into account in the preview window.

    For example:
    <?
    include ('../php/include/artikel_header.php');
    ?>
    

    I installed php on my laptop, do I have to specify in HTMK-Kit Tools where it is installed?
    I use the include functionality a lot, so my articles look bare in the preview window.

    Kind regards,

    Ivo.

    • IvoAelberts, 10th Aug 2012 5:31 am

      My example was stripped from the text, I guess posting the php code is not allowed for security reasons.
      The example contained a php include statement which includes another php file.

      • HTML-Kit Support, 10th Aug 2012 2:40 pm

        On 8/10/2012 5:31 AM, IvoAelberts wrote:

        My example was stripped from the text, I guess posting the php code
        is not allowed for security reasons.
        The example contained a php include statement which includes another
        php file.

        Hi Ivo,

        Your example PHP code should now appear in the post. The trick is to
        start lines that contain code with 4 or more spaces, and then the forum
        software will show it in a box with proper escapes :)

        Since you have PHP installed on your laptop, you can use "View > Preview

        Preview through PHP interpreter" option. But, for best results, it's
        better to install a local web server and preview through it.

        "View > Preview > Preview server-side script" is one way to do it. I'm
        also working on adding this to Ctrl+F12 preview so you could see the
        preview update automatically when you save scripts.

        I've added you to the TreeHouse. This way you'll have faster access to
        upcoming features like server-side preview in landscape mode :)

        Chami

        • IvoAelberts, 11th Aug 2012 9:50 am

          Hi Chami,

          Thanks, I see now all the different options for previewing. I tried previewing through the php interpreter, but somehow it does not process the include statement (or it cannot find the included file).

          Did I something wrong?

          Kind regards, Ivo.

          • HTML-Kit Support, 11th Aug 2012 10:57 am

            On 8/11/2012 9:50 AM, IvoAelberts wrote:

            Hi Chami,

            Thanks, I see now all the different options for previewing. I tried
            previewing through the php interpreter, but somehow it does not
            process the include statement (or it cannot find the included file).

            Did I something wrong?

            Kind regards, Ivo.

            I don't think you did anything wrong, Ivo. php.exe may not be finding
            the include file because it's a relative path. To see if this is the
            case you could, only temporarily as a test because the paths should be
            relative, try an absolute path like:

             include ('c:/mysite/php/include/artikel_header.php');
            

            This is why I'd generally preview PHP (or really any server-side script)
            through a local web server. A web server would be able to properly
            translate relative paths and serve the correct file. If you're not using
            any other PHP functions, setting up a local test server may sound like
            overkill. If you're using PHP for more than including files though, a
            local server would get you the most accurate preview.

            Chami

            • IvoAelberts, 12th Aug 2012 4:58 am

              Hi Chami,

              I think you are right (didnt test it, too much include files).
              I saw the "preview with server files" option, for me that is the best option. I have a test site operational which automatically links to a test SQL database. I just have to upload the file each time it is changed (or link it to an upload locarion).

              Is it an option to include some kind of "publish"option in HTML-Kit tools in which you can select the environment on which will be published? For example, normally I publish tot TEST, except when the test version is ready then I publish to PROD.
              The FTP functionality you have implemented now works great, but when a file is ready to go to my production location I have to link it to another FTP location. It would be much easier if I can give a relative publishing path (e.g. www.hrkennis.nl for PROD or www.hrkennis.nl/2punt0/ for TEST) and have a button to publish to a particular location (TEST or PROD).

              Thanks again for your help.

              Kind regards, Ivo.

              • IvoAelberts, 12th Aug 2012 5:47 am

                Chami,

                Now I'm using this ""preview with server files" option, each time when I type in HTML-Kit tools, Windows asks me if I want to download or open a file: filename_preview_ext.php.

                The message is popping op constantly. when I choose "open" the file is opened in HTLM-Kit tools in the edit window (not in the preview window). when I choose FireFox as default for php files, it opens Firefox and wants to download the file (no option to view it).

                For now, I have to turn of this preview option.
                What am I doing wrong ?

                Kind regards, Ivo.

                • HTML-Kit Support, 12th Aug 2012 8:55 am

                  On 8/12/2012 5:47 AM, IvoAelberts wrote:

                  Chami,

                  Now I'm using this ""preview with server files" option, each time
                  when I type in HTML-Kit tools, Windows asks me if I want to download
                  or open a file: filename_preview_ext.php.

                  The message is popping op constantly. when I choose "open" the file
                  is opened in HTLM-Kit tools in the edit window (not in the preview
                  window). when I choose FireFox as default for php files, it opens
                  Firefox and wants to download the file (no option to view it).

                  For now, I have to turn of this preview option.
                  What am I doing wrong ?

                  Kind regards, Ivo.

                  Hmm... assuming that you're going through a local web server and if this
                  is the first time it's being used, do the *.php files have the correct
                  file type / MIME in the server? I'd try renaming one of the files to
                  *.php5 and entering the URL directly in Firefox to see what happens.

                  If MIME type isn't the issue, has anything else changed since the last time?

                  Chami

                  • IvoAelberts, 13th Aug 2012 5:02 am

                    Hi Chami,

                    Ok, I thought I was able to use my remote web server for this previewing option. Can this option only be used using a local server ?

                    The preview window looks good using the remote server address, but the download window is constantly popping up.

                    Kind regards, Ivo.

                    • HTML-Kit Support, 13th Aug 2012 9:54 am

                      On 8/13/2012 5:02 AM, IvoAelberts wrote:

                      Hi Chami,

                      Ok, I thought I was able to use my remote web server for this
                      previewing option. Can this option only be used using a local server
                      ?

                      The preview window looks good using the remote server address, but
                      the download window is constantly popping up.

                      Kind regards, Ivo.

                      You can definitely use a remote server to preview server-side scripts.
                      The main advantage to using a local server though is that you can
                      directly map it to use local files without having to upload.

                      Are you able to view/preview any *.php through this server? What happens
                      when you directly open it in a browser? If you continue to have any
                      problems, and if you don't mind posting the URL to a sample script on
                      this remote server, I can preview it here and see what happens.

                      Chami

                      • IvoAelberts, 14th Aug 2012 4:25 am

                        Hi Chami,

                        In a normal browser, viewing the PHP file is no problem. For example e new article (in dutch) im working on you can also view on the prod site bij using the direct url:

                        www.hrkennis.nl/artikelen/wul.php

                        This article is not present in the main website but by directly using the url its visible (working on that)..

                        When I use the URL (www.hrkennis.nl/artikelen/wul.php) in the preview window of HTML Kit Tools, I keep getting the download popups. When I set HTML-Kit Tools default for PHP files, the downloaded file is opned but in the main window (the edit window, not the preview window). When I set IE as default for PHP files, it shows me a download screen without the option to actually view the file in IE. Same for FireFox.

                        When I directly type the link into the browser (www.hrkennis.nl/artikelen/wul.php), there is of course no problem. The page is viewed perfectly.

                        Thanks for looking into this.

                        Kind regards,

                        Ivo.

                        • HTML-Kit Support, 14th Aug 2012 9:57 am

                          On 8/14/2012 4:25 AM, IvoAelberts wrote:

                          Hi Chami,

                          In a normal browser, viewing the PHP file is no problem. For example
                          e new article (in dutch) im working on you can also view on the prod
                          site bij using the direct url:

                          www.hrkennis.nl/artikelen/wul.php

                          This article is not present in the main website but by directly
                          using the url its visible (working on that)..

                          When I use the URL (www.hrkennis.nl/artikelen/wul.php) in the
                          preview window of HTML Kit Tools, I keep getting the download popups.
                          When I set HTML-Kit Tools default for PHP files, the downloaded file
                          is opned but in the main window (the edit window, not the preview
                          window). When I set IE as default for PHP files, it shows me a
                          download screen without the option to actually view the file in IE.
                          Same for FireFox.

                          When I directly type the link into the browser
                          (www.hrkennis.nl/artikelen/wul.php), there is of course no problem.
                          The page is viewed perfectly.

                          Thanks for looking into this.

                          Kind regards,

                          Ivo.

                          Hi Ivo,

                          I just did a quick test previewing www.hrkennis.nl/artikelen/wul.php in
                          Tools using "View > Preview > Server-side script." I didn't get a
                          download prompt myself so I'm wondering if it's the file associations.
                          If you're still getting a prompt, please try setting *.php and *.html
                          files to IE. In general though, this should work without an issue given
                          that *.php files are serving text/html.

                          Let me know if this doesn't help.

                          Chami

                          • IvoAelberts, 15th Aug 2012 4:16 am

                            Hi Chami,

                            I tried this but it did not help.

                            Somehow, I only get the download prompt when I change the php file in HTML-Kit tools. For example, I put a space in the php file and a minute later the download prompt appears. When I do not change the file, I do not get the download prompt.

                            The file is associated with the FTP location in HTML-Kit tools (saved to the FTP location from which I was previewing). But I also get the download prompt if the file is only changed (and not saved) in HTML-Kit tools.

                            Can my settings in HTML-Kit tools be wrong?
                            I know I have been experimenting with the preview settings.

                            Kind regards, Ivo.

                            • HTML-Kit Support, 16th Aug 2012 9:23 am

                              On 8/15/2012 4:16 AM, IvoAelberts wrote:

                              Hi Chami,

                              I tried this but it did not help.

                              Somehow, I only get the download prompt when I change the php file in
                              HTML-Kit tools. For example, I put a space in the php file and a
                              minute later the download prompt appears. When I do not change the
                              file, I do not get the download prompt.

                              The file is associated with the FTP location in HTML-Kit tools
                              (saved to the FTP location from which I was previewing). But I also
                              get the download prompt if the file is only changed (and not saved)
                              in HTML-Kit tools.

                              Can my settings in HTML-Kit tools be wrong? I know I have been
                              experimenting with the preview settings.

                              Kind regards, Ivo.

                              Sorry about the slow reply, Ivo.

                              I'm not sure what's happening here. It's possible to test this with
                              default settings by selecting a profile you haven't used before from
                              "Kit > Profiles" menu.

                              If you have another application associated to PHP files though IE may
                              continue to show download prompt thinking that the file should be
                              downloaded instead of viewed within. I'm updating landscape preview to
                              support server-side scripts and will add an option to ignore file
                              associations when previewing.

                              Chami

                              • IvoAelberts, 17th Aug 2012 3:59 am

                                Hi Chami,

                                "
                                I'm updating landscape preview to
                                support server-side scripts and will add an option to ignore file
                                associations when previewing.

                                "

                                Thanks, I think that will fix it for me.

                                I will do some more tests to understand why exactly this is happening and will let you know as soon as i know more.

                                Kind regards,

                                Ivo.