PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Embedding results in a dynamic page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Embedding results in a dynamic page

    Our web page template is generated using PHP, not static HTML

    I've been able to get the Zoom results into the PHP page by manually editing the Settings.php file and changing the '$TemplateFilename' value to "http://our.website.com/search_template.php" so that it is processed by PHP before being processed by Search.php (IYSWIM)

    However, whenever I regenerate the search, I need to change this file manually again.

    Is there a setting somewhere I'm missing in the Zoom configuration which sets this option through there?

  • #2
    You should not need to edit the settings.php file.

    Rather see the instructions here,
    http://www.wrensoft.com/zoom/support/faq_ssi.html

    ---
    David

    Comment


    • #3
      Thanks

      (Changing the $TemplateFilename setting works just as well, and seems easier to me though.. )

      Comment


      • #4
        The settings file contains a bunch of important data that needs to be correct (like the number of records in the index files). So this file needs to be overwritten each time the index is updated.

        -----
        David

        Comment


        • #5
          Changing the $TemplateFilename in settings.php will not work in most cases, because the PHP code in your template will not be processed. It will only work if your template file does not contain PHP commands, in which case, the file would essentially be static HTML despite the fact that it has been given a PHP extension. Perhaps that is what's actually happening for you? Or do you have a special server configuration setup to allow PHP commands to be executed from the output of a PHP script?
          --Ray
          Wrensoft Web Software
          Sydney, Australia
          Zoom Search Engine

          Comment


          • #6
            Originally posted by Ray
            Changing the $TemplateFilename in settings.php will not work in most cases, because the PHP code in your template will not be processed. It will only work if your template file does not contain PHP commands, in which case, the file would essentially be static HTML despite the fact that it has been given a PHP extension.
            Sorry, but that's not right at all..

            PHP lets you specify URLs in file open/read commands, so if you open a 'file' called "http://www.site.com/index.php", PHP will read that file from the web server - AFTER the server's PHP has processed it. So, the reading PHP script will see the output of the PHP script, not the source of the PHP script. The PHP script can read files from totally different servers this way.

            Well, this is the case if 'fopen_wrappers' have been enabled (which is usually the case, and is the default in Windows versions of PHP)

            Zoom uses the 'file' command to read the file into the array, if you specify a URL as the filename (as I said in my OP), it reads the contents of that URL, JUST AS IF you were reading it from a web browser.

            See http://uk2.php.net/manual/en/function.fopen.php and
            http://uk2.php.net/manual/en/wrappers.php

            Try it and see.

            For a quick test, make a PHP script something like:

            Code:
            <?php
            echo "
            
            This is Zoom's search page</p>";
            $f = file&#40;'http&#58;//www.wrensoft.com/search.php'&#41;;
            for&#40;$i=0;$i<sizeof&#40;$f&#41;;$i++&#41; echo "$i&#41; ".htmlentities&#40;$f&#91;$i&#93;&#41;."
            ";
            ?>
            This will print out the output of the search.php script on the Wrensoft site.

            Comment


            • #7
              You are mostly correct, but note that there are two important additional criterias. First of all, fopen will only see the output of the PHP script if the filename specified is an absolute URL of the form "http://www.mysite.com/page.php".

              Zoom does not use an absolute URL for the template filename. This way, the search engine can be placed in any folder of your website (or on a completely different website all together) - so long as all the files are in the same folder. If we were to introduce this requirement, we would then need users to specify exactly where the files will be, and we also lose the flexibility of allowing the files to be moved. This is important, as it increases the number of dependant variables involved in an installation.

              So to clarify, yes, changing TemplateFilename in settings.php will work but ONLY if you specify an absolute URL for the filename AND if your server has allow_url_fopen enabled.

              However, we do not recommend this. The supported method of usage to achieve the same thing (a dynamically generated search template/layout) is described here:
              http://www.wrensoft.com/zoom/support/faq_ssi.html

              This method would not require any changes to the settings file, nor does it require an absolute URL for the template file. It will also work on servers that have allow_url_fopen disabled (note that allow_url_fopen is commonly disabled - especially on servers offering shared hosting, because it is a significant security risk).
              --Ray
              Wrensoft Web Software
              Sydney, Australia
              Zoom Search Engine

              Comment

              Working...
              X