Announcement

Collapse
No announcement yet.

Output variable content in block if

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

    #16
    That's a quirk of the PHP heredoc syntax and Actinic using \ in file paths when previewing.

    The filename will be products\13645.jpg and heredoc sees that as \136 followed by 45.

    It should all be OK on the live site as the filename there will be only 13645.jpg.

    My Tabber uses heredoc and there's never been any problems there. Image paths seem to be the most likely problem area.

    Other things are interpreted by heredoc so be forewarned (although they should be OK on the live site). These are:

    \n linefeed (LF or 0x0A (10) in ASCII)
    \r carriage return (CR or 0x0D (13) in ASCII)
    \t horizontal tab (HT or 0x09 (9) in ASCII)
    \v vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5)
    \f form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
    \\ backslash
    \$ dollar sign
    \" double-quote
    \[0-7]{1,3} the sequence of characters matching the regular expression is a character in octal notation
    \x[0-9A-Fa-f]{1,2}

    So you might also have problems with images in sub-folders whose filenames start with n, r, t, v, f, x.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      And, in case anyone from Actinic is listening, it would be great to use PHP 5.3.0 or later since that has the nowdoc syntax. No parsing is done at all inside a nowdoc.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #18
        Also, you can workaround this quirk. Edit layouts Standard Product Image / Small Product Image and replace:
        Code:
        <img src="<actinic:variable name="ProductImageFileName" />"
        with:
        Code:
        <img src="<actinic:block php="true">echo str_replace('\\', '/', '<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />');</actinic:block>"
        And this will turn all \ into the non-escape character / in Product Image filenames.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #19
          We can also extend this to provide the results in a sorted order.

          Copy layout Grouped Products List and rename the copy to be Grouped Products List by Name.
          Replace all code in Grouped Products List by Name with the following:
          Code:
          <actinic:block php="true">
          	$products = array();
          	$prices = array();
          	$index = 0;
          	$GroupToShow = '<actinic:variable name="GroupToShow" encoding="perl" selectable="false" />';
          	<actinic:block type="EntireSectionList">
          		<actinic:block type="ProductList">
          			if ( (<actinic:variable name="ProductType" selectable="false" /> == 0) 
          				&& ('<actinic:variable name="Group" encoding="perl" selectable="false" />' == $GroupToShow)
          				)
          				{
          				$productcode = <<<ENDOFLAYOUT
          <actinic:variable name="ProductLayout" value="Product Summary" />
          ENDOFLAYOUT;
          				$prices[$index] = '<actinic:variable name="ProductName" encoding="perl" selectable="false" />';
          				$products[$index++] = $productcode;
          				}
          		</actinic:block>
          	</actinic:block>
          	asort ($prices, SORT_STRING);
          	foreach ($prices as $key => $val) {echo $products[$key];}
          </actinic:block>
          Again copy layout Grouped Products List and rename the copy to be Grouped Products List by Price.
          Replace all code in Grouped Products List by Price with the following:
          Code:
          <actinic:block php="true">
          	$products = array();
          	$prices = array();
          	$index = 0;
          	$GroupToShow = '<actinic:variable name="GroupToShow" encoding="perl" selectable="false" />';
          	<actinic:block type="EntireSectionList">
          		<actinic:block type="ProductList">
          			if ( (<actinic:variable name="ProductType" selectable="false" /> == 0) 
          				&& ('<actinic:variable name="Group" encoding="perl" selectable="false" />' == $GroupToShow)
          				)
          				{
          				$productcode = <<<ENDOFLAYOUT
          <actinic:variable name="ProductLayout" value="Product Summary" />
          ENDOFLAYOUT;
          				$prices[$index] = <actinic:variable name="ProductPriceRaw" />;
          				$products[$index++] = $productcode;
          				}
          		</actinic:block>
          	</actinic:block>
          	asort ($prices, SORT_NUMERIC);
          	foreach ($prices as $key => $val) {echo $products[$key];}
          </actinic:block>
          Now you can choose a layout for the dummy Fragment that displays in Section, Name, or Price order.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #20
            Originally posted by NormanRouxel View Post
            And this will turn all \ into the non-escape character / in Product Image filenames.
            A simple fix that worked a treat. Brilliant work as ever Norman.


            Bikster
            SellerDeck Designs and Responsive Themes

            Comment


              #21
              Thanks Norman, for the solution. This is what I was trying to achieve when I posted http://community.actinic.com/showthread.php?t=51829

              I've implemented the sorted by Name which works great. However, I need a 3-column display to match the display under other sections where real products are under the sections. See attached images.

              Replacing ProductLayout with a Product list, it seems to thrah the DB quite a bit & then generate a cartesean products. i.e. If just 4 products meet the criteria, it will display all 4 products in 4 identical lines. If 5 products are met, then it will display 5 identical lines of all 5 products. See attached images. As the output is from a fragment, I can't seem to use ColumnCountOfProducts.

              Any help would be much appreciated.
              Many Thanks Nilesh.
              Attached Files

              Comment


                #22
                Use inbuilt PHP to keep a loop count of the items you output. E.g.
                Code:
                <actinic:block php="true">$itemcount = 0;</actinic:block>
                START YOUR LOOP HERE
                 Output item
                  <actinic:block php="true">
                    if ($itemcount++ > 3) 
                      {
                      echo '<br clear="all" />';
                      $itemcount = 0;
                      }
                  </actinic:block>
                END YOUR LOOP HERE
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #23
                  Hello Norman

                  it would be great to use PHP 5.3.0 or later since that has the nowdoc syntax. No parsing is done at all inside a nowdoc
                  I have raised an issue for this now. Thanks for bringing it up.

                  Regards
                  Krithika Chandrasekar
                  SellerDeck

                  sigpic

                  E-commerce software by SellerDeck

                  Comment


                    #24
                    Krithika,

                    That would be a very welcome update.

                    Actinic uses heredoc syntax internally (2 places in actinic_main.php and a couple of times in layouts Push Button Grid and Variant Selector).

                    Since it's somewhat sensitive to unusual customer data it would be nice to fix that vulnerability.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #25
                      Thanks for the suggestion, Norman.

                      Its probably me, but I'm not getting the desired affect.
                      If I use PRODUCTLIST, Actinic hangs for a while & then displays n lines with n products. If I use PRODUCTLAYOUT, it simply list one after the other but not in 3 columns. Am I suppose to be using PRODUCTLISTLAYOUT or PRODUCTLAYOUT? Also, have I mis-coded it...... again?

                      Many Thanks, Nilesh


                      PHP Code:
                      <actinic:block php="true">
                          
                      $BrandToShow '<actinic:variable name="FBrand" />';
                          
                      $StyleToShow '<actinic:variable name="FStyle" />';
                          
                      $itemcount 0;
                          <
                      actinic:block type="EntireSectionList">
                              <
                      actinic:block type="ProductList">
                                  if ( (<
                      actinic:variable name="ProductType" selectable="false" /> == 0
                                      && (
                      '<actinic:variable name="Brandname" encoding="perl" selectable="false" />' == $BrandToShow)
                                      && (
                      '<actinic:variable name="ManufacturersStyle" />' == $StyleToShow)
                                      )
                                      {
                                      
                      $productcode = <<<ENDOFLAYOUT
                      <actinic:variable name="ProductLayout" />
                        <actinic:block php="true">
                        print 
                      $itemcount;
                          if (
                      $itemcount++ > 3) 
                            {
                            echo '<br clear="all" />';
                            
                      $itemcount = 0;
                            }
                        </actinic:block>


                      ENDOFLAYOUT;
                                      echo 
                      $productcode;
                                      }
                              </
                      actinic:block>
                          </
                      actinic:block>
                      </
                      actinic:block

                      BTW - I incorporated a print statement to see what gets calculated. It displays 3,4,0 &1 but No digit 2.

                      Comment

                      Working...
                      X