Announcement

Collapse
No announcement yet.

SectionName vs. SectionImageFileName

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

    SectionName vs. SectionImageFileName

    I'm trialing Actinic Designer 8.5.0.

    The product section pages normally show the value of the 'SectionName' tag. I want to make a set of section images, and I'll put them in a folder named 'headers' - the filenames will be the same as the SectionName but with a .png suffix.

    How can I change the code so that it displays 'headers/SectionImageFileName.png' if the file exists, but reverts to display 'SectionName' if no image file exists?

    Many thanks...

    #2
    Use inline PHP. E.g. (untested)

    Code:
    <actinic:block php="true">
    $sname = '<actinic:variable name="SectionName" encoding="perl" selectable="false" />';
    $fname = 'headers/' . str_replace('.jpg', '.png', $sname);
    if (file_exists($fname))
      {
      echo '<img src="' . $fname . '" />';
      }
    else
      {
      echo $sname;
      }
    </actinic:block>
    However it would be a lot easier to simply create a new Variable of type filename and add your images there.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Well, I can't get it to work. My web site is hosted on a Linux server with Apache and PHP4 AND PHP5 (I can select which one).

      Using the above code I couldn't get it to work, and I then discovered that the file_exists() function needs to reference the FULL path to the file i.e.:-

      /home/mydomain/public_html/acatalog/headers/picture.png

      However, in Actinic, the code still does not work although I copied the code into a PHP script and uploaded it to my website and that DID work...

      So, does Actinic parse PHP by itself? Or does it use the server installed PHP?

      Comment


        #4
        Actinic parse PHP by itself? Or does it use the server installed PHP
        This code is not for your server. Actinic has the entire PHP4 language embedded and this is available for inserting into your Layouts, where it can process Actinic Variables and echo output into the generated HTML. That's what the above does.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Originally posted by christopherpm
          Well, I can't get it to work. My web site is hosted on a Linux server with Apache and PHP4 AND PHP5 (I can select which one).

          Using the above code I couldn't get it to work, and I then discovered that the file_exists() function needs to reference the FULL path to the file i.e.:-

          /home/mydomain/public_html/acatalog/headers/picture.png

          However, in Actinic, the code still does not work although I copied the code into a PHP script and uploaded it to my website and that DID work...

          So, does Actinic parse PHP by itself? Or does it use the server installed PHP?
          Hi, was this resolved?

          I am doing something similar and am having a problem with it.

          I'm using an Actinic block of PHP to confirm an image exists before displaying the image, if it does not exist i wish to display a default image.

          However file_exists consistently returns false when used in an Actinic block where the same PHP code returns true when it is independent of Actinic.

          Comment


            #6
            Welcome, Elaine

            Make sure you use something like

            $myfile = '<actinic:variable name="myfilename" encoding="perl" selectable="false" />';

            These extra taglets are needed to escape special characters properly and to prevent Actinic from adding extra code in the Design view.

            Also why not put in a few temporary echo statements so you can see what's in your variables.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Thanks Norman but i still haven't managed to get it to work.

              Code:
              <actinic:block php="true">
              $sname='<actinic:variable name="CurrentAccount" encoding="perl" selectable="false"/>';
              $fname="D:\mydomain\www\acatalog\logo_".$sname.".gif";
              echo $fname;
              if (file_exists($fname))
                {
                //echo '<img src="' . $fname . '" />';
                echo "<!--image exists-->";
                }
              else
                {
                 echo "<!-- image doesn't exist, use default image-->";
                }
              </actinic:block>
              The file does exist and when i echo the variable $fname it contains the full path & fiilename correctly, however file_exists() returns false

              Comment


                #8
                This looks to me as though you are trying to look at a file on your Server. Actinic code runs at page build time and only knows about files on your Actinic PC.

                Try testing with a file in your Site folder and just the file name (lose all that D:\... stuff).
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  Thanks again Norman. I'm now finding the images however because it's run at the page build stage i'm not sure its possible to do what i want to do

                  What i'm trying to achieve is that when an account holders logs in the default/generic banner image changes to their own custom banner. However if their own custom banner file doesn't exist the default banner is shown.

                  The custom image is named using a naming convention
                  <actinic:variable name="CurrentAccount"/>_logo.gif

                  Comment


                    #10
                    Hmmm. Tricky. Assuming you can get the current account ID into the pages HTML, you could investigate something like

                    <img src="custbanner.php?id=<CUSTOMERID>" />

                    and have some PHP custbanner.php on the server that parses the query string and returns an image (not HTML) that depends on whether such a file exists. If no match it returns a default image.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment

                    Working...
                    X