Announcement

Collapse
No announcement yet.

variable encoding for a variable file name

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

    variable encoding for a variable file name

    Anybody got any idea which of the encodings is best for a filename variable that then needs to be used in javascript.

    I have at the moment used:

    Code:
    <script language="JavaScript" type="text/javascript">
      <!--
       //we need to find \ and change to /
       var sActSecondImg = '<actinic:variable encoding="perl" name="ACTSECONDIMG" selectable="false" />';
       var sActThirdImg = '<actinic:variable encoding="perl" name="ACTTHIRDIMG" selectable="false" />';
       var sActFourthImg = '<actinic:variable encoding="perl" name="ACTFOURTHIMG" selectable="false" />';
       var sActFifthImg = '<actinic:variable encoding="perl" name="ACTFIFTHIMG" selectable="false" />';  
       var sProductName='<actinic:variable encoding="perl" name="ProductImageFileName" selectable="false" />';
     
       sActSecondImg=sActSecondImg.replace(/\\/g,"/");
       sActThirdImg=sActThirdImg.replace(/\\/g,"/");
       sActFourthImg=sActFourthImg.replace(/\\/g,"/");
       sActFifthImg=sActFifthImg.replace(/\\/g,"/");
       sProductName=sProductName.replace(/\\/g,"/");
     
       if (sActSecondImg) document.write("<img src='"+sActSecondImg+"' alt='alternate image' width='70' class='thumb' onmouseover=\"document.getElementById('mainimage').src='"+sActSecondImg+"';\" onmouseout=\"document.getElementById('mainimage').src='"+sProductName+"';\">");
       if (sActThirdImg) document.write("<img src='"+sActThirdImg+"' alt='alternate image' width='70' class='thumb' onmouseover=\"document.getElementById('mainimage').src='"+sActThirdImg+"';\" onmouseout=\"document.getElementById('mainimage').src='"+sProductName+"';\">");
       if (sActFourthImg) document.write("<img src='"+sActFourthImg+"' alt='alternate image' width='70' class='thumb' onmouseover=\"document.getElementById('mainimage').src='"+sActFourthImg+"';\" onmouseout=\"document.getElementById('mainimage').src='"+sProductName+"';\">");
       if (sActFifthImg) document.write("<img src='"+sActFifthImg+"' alt='alternate image' width='70' class='thumb' onmouseover=\"document.getElementById('mainimage').src='"+sActFifthImg+"';\" onmouseout=\"document.getElementById('mainimage').src='"+sProductName+"';\">");
      // -->
      </script>
    but wondered if there was a cleaner solution.
    Wayne Theisinger

    The Web's just settling in. We got the tech, now let's put up something that matters.

    #2
    php is a cleaner solution.

    in your main php file (C:\Program Files\Actinic v8\actinic_main.php)
    PHP Code:
    function MakeImg($src) {
        echo 
    "<img src=\"".$src."\" />";

    in your template:
    PHP Code:
    if ("<actinic:variable name="ProductImageFileName" />"<>"") {MakeImg("<actinic:variable name="ProductImageFileName" />")}; 
    *warning psudocode*

    Comment


      #3
      ah - now there's an idea - so do the writing of the image tag in php and then when it hits html for the client site, it is already the right format. Right will do that then.

      Thanks.
      Wayne Theisinger

      The Web's just settling in. We got the tech, now let's put up something that matters.

      Comment


        #4
        I use PHP like this

        Code:
        <actinic:block php="true>
        $image = str_replace( '\\', '/', '<actinic:variable encoding="perl" name="ACTSECONDIMG" selectable="false" />');
        if ( $image ) echo '<img src="' . $image . '"/>';
        </actinic:block>
        That str_replace is very important if you intend to use these image filenames within JavaScript and get them to Preview properly (during Preview the path to the image is used). If you left them as-is, images sourced from folders beginning with e.g. t would look contain strings like \t and the JavaScript might interpret that as a tab character.

        PS I have a patch ( Multi Product Images - see http://www.drillpine.biz/v8multiprod...tproducts.html ) that does what you seem to be trying to achieve. It automatically creates scaled down icons and does a lot of other stuff. It contains 271 lines of PHP and uses an image processing library containing another 141 lines!
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment

        Working...
        X