Announcement

Collapse
No announcement yet.

Using PHP in Fragments

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

    Using PHP in Fragments

    Hi

    First off I know nothing about PHP so please excuse my ignorance.

    I want to add a PHP knowledge base to a web site.

    The software instructions say to create a php page on web site and insert php code.

    However before I purchase the software I though I best make sure it would work so created a brochure page and renamed it faq.php then inserted a block php="true" in a fragment with some sample php as below -

    !!<
    <actinic:block php="true">
    <? print("Hello") ?>
    </actinic:block>
    >!!

    However I get a parse error on line 2 when published live.

    Help please!

    #2
    Originally posted by simplydigital View Post
    Hi

    First off I know nothing about PHP so please excuse my ignorance.

    I want to add a PHP knowledge base to a web site.

    The software instructions say to create a php page on web site and insert php code.

    However before I purchase the software I though I best make sure it would work so created a brochure page and renamed it faq.php then inserted a block php="true" in a fragment with some sample php as below -

    !!<
    <actinic:block php="true">
    <? print("Hello") ?>
    </actinic:block>
    >!!

    However I get a parse error on line 2 when published live.

    Help please!
    Actinic publishes html files, you can't run PHP inside html files other than by putting it inside a script tag.

    <script src="../plugins/viewWishList.php" type="text/javascript" language="javascript"> </script>

    not strictly kosher as the script is defined as javascript but it does work..

    Malcolm

    SellerDeck Accredited Partner,
    SellerDeck 2016 Extensions, and
    Custom Packages

    Comment


      #3
      !!<
      <actinic:block php="true">
      <? print("Hello") ?>
      </actinic:block>
      >!!
      The actinic:block stuff does the same job within Actinic as the PHP <?php and ?>. So try it without these. E.g.
      Code:
      !!<
      <actinic:block php="true">
      print("Hello");
      </actinic:block>
      >!!
      Note also that PHP statements need a ; at the end.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks for your help Norman

        This works, so I pressume the knowledge base will as well.

        Steven

        Comment


          #5
          The software instructions say to create a php page on web site and insert php code
          I was answering your question about a bit of PHP being parsed by Actinic. This is PHP that's executed by Actinic when it's building that particular page. You probably saw "Hello" on the page when Previewing because Actinic executed that PHP and incorporated its output into the generated page.

          However you want something different. You need a big PHP program to run on a particular Brochure page. In this case, name the brochure page so that it ends in .php and include this code on it.
          Code:
          !!<
          <?php
           print("Hello from the web server"); 
          ?>
          >!!
          Now you won't see anything when Previewing but should when you view that page on your web-server.

          If you're confused by the two different ways that PHP can be interpreted, then try this little lump of code that displays the date and time twice:
          Code:
          !!<
          <actinic:block php="true">
          print "Actinic generated: " . date("F j, Y, g:i:s a ");
          </actinic:block>
          >!!
          
          !!<
          <?php
          print "Server generated: " . date("F j, Y, g:i:s a");
          ?>
          >!!
          Upload (as a .php page) and look at what you get. Try refreshing the page.

          The "Actinic generated" date won't change as this was done once when the page was made by Actinic and the resulting date was "printed" into the HTML generated for that page.

          The "Server generated" date will change each time you refresh the page as this code is executing on your server.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Once again thanks Norman.

            I have managed to set up the knowledge base and integrate it into actinic, however there is a ?php include_once command that has to go before the head on the page.

            To get round this I have simply edited the faq.php page directly on the server (I understand that every upload will need to edit this).

            If I simply put the ?php include_once on the content page will this work and if so will it slow the web site as it is loading a php file on every page?

            Thanks

            Steven

            just in case the knowledge base is here

            Comment


              #7
              Set the title of that particular page to something unique. Like "My Brochure Page".

              Use a blockif in your overall layout so that the include is only generated on that page.

              Like:
              Code:
              <actinic:block if="%3cactinic%3avariable%20name%3d%22PageTitle%22%20%2f%3e%20%3d%3d%20%22My%20Brochure%20Page%22">
                <?php include_once "myfile.php"; />
              </actinic:block>
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment

              Working...
              X