Announcement

Collapse
No announcement yet.

Output variable content in block if

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

    Output variable content in block if

    I have a variable which uses drop down choices which are assigned at section level. The choices are simple text options eg:

    Grape
    --- Chardonnay
    --- Shiraz
    --- Merlot

    Is it possible to dump the setting of the section level variable text into a block if?

    I can test for the variable meets a certain string eg:

    Grape == "Chardonnay"

    But I need to dump the actual value "Chardonnay" into the block if as set at the section level to test against another variable without having to write lots of "AND/OR"

    eg:

    NewVariable == "value of Grape variable"

    where "value of grape variable" is replaced dynamically depending on the value declared at the specific section level... in this case "Chardonnay" so it would read when parsed :

    NewVariable == "Chardonnay"


    Bikster
    SellerDeck Designs and Responsive Themes

    #2
    You can extract the variable value from the database based on the current section and then you should be able to use it in a blockif. I did something similar in v10 recently and, much to Norman's surprise, it worked when tested in the blockif.

    See here: http://community.actinic.com/showthread.php?t=51668

    Comment


      #3
      Nice. Missed that from before.

      My PHP database skills are as talented as Jedward but I can only break it so here goes.


      Bikster
      SellerDeck Designs and Responsive Themes

      Comment


        #4
        Not quite sure what you're doing, but there should be no problem compaing two variables in a BlockIf. E.g:

        MyVar1 == MyVar2
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Funnily enough it is similar as to what Duncan was doing in his thread as linked above. I have a variable set at the product level and then have different product lists used to show only products which match the variable. At the moment I have manually created multiple product lists with the variable options set eg:

          EntireSectionList
          ProductList
          Block if .. grape1 == "Chardonnay"

          This shows a section with all products matching the variable "Chardonnay"... but I have had to create product lists for all the options in the variable (Merlot, Shiraz etc)

          What I am hoping to achieve is to make this more dynamic by using just one special product list for many sections with a section variable set to say "Chardonnay" and this outputs the results of all products matching "Chardonnay"

          But the PHP/SQL extraction is beyond me.


          Bikster
          SellerDeck Designs and Responsive Themes

          Comment


            #6
            You can play around getting the query correct in MS Access and then copy it as a Query and use it in the code. I also find Flyspeed SQL Query useful to test with: http://www.activedbsoft.com/download-querytool.html

            Comment


              #7
              In abject fear of databases (ignorance is bliss) I have been toying with the inbuilt PHP and sort of just about got there. In lay code:

              2 variables

              grapesection - set at the section level
              grape1 - set at the product level


              In the Product List
              Code:
              PHP Block
              $sFilter = "grapesection";
              echo $sFilter;
              /block
              
              EntireSectionList
              EntireProductList
              
              Block if
              $sFilter == grape 1
              
              ProductLayout
              This echoes the correct grapesection variable for each section BUT it appears to retain the variable to whichever section I close Actinic and launch into.

              So if in Chardonnay and switch to Shiraz the echo shows "Shiraz" but the products are all Chardonnay. Stay on Shiraz section and restart Actinic the products and echo show Shiraz but switch to Chardonnay and the echo shows Chardonnay but the products are Shiraz. This is local view only - not tried an upload.

              So why is the $sFilter being remembered between sections in the block if and but the echo?


              Bikster
              SellerDeck Designs and Responsive Themes

              Comment


                #8
                I think you might be over engineering Jonty, can't you create a section/product level variable with use parent in place, set default value to be empty along with your choices. When this is empty the list proceeds as normal, and it filters on your variable choices if one has been selected and thus casacaded down to the sections/products. You can get a productlist just filtering on a variable contents, just make sure you have a dummy blank fragment added to the page so that actinic in initiates a list.

                Your php woes are probably two-fold a) you're not clearing the contents of the variable so perhaps sustaining the value and something has to make the php run again, i suspect the way you have it, it does not do that so only right when first run perhaps.

                Comment


                  #9
                  Clear the content by doing this at the very top just after you open the php block:

                  $sFilter = "";

                  Comment


                    #10
                    I have tried all levels of simple through complex. I think the main issue is in using the EntireSectionList and then the EntireProductList ... it is not accepting the section variable from where the Product List is being declared but searching through the whole database (from start to end in order) ... hence my previous fix by hardcoding the variable values into the block if and setting up as many Product Lists as there are variables.

                    It is going off and finding everything without paying notice to what is set at the section level they are filtering back into.


                    Bikster
                    SellerDeck Designs and Responsive Themes

                    Comment


                      #11
                      Originally posted by leehack View Post
                      Clear the content by doing this at the very top just after you open the php block:

                      $sFilter = "";
                      Will report back on that - off to walk the hound in sub-zero torrential rain to clear my head.


                      Bikster
                      SellerDeck Designs and Responsive Themes

                      Comment


                        #12
                        When i managed auto lists, i'm sure i just had one variable settable at both section and product level with use parent in place. I could run section lists filtering on sections where this was set and also auto product lists that filtered on it, but I did need the dummy empty fragment to initiate the product list, actinic wouldn't work without that.

                        I think i had one variable for the setting and then one variable (a mirror) so i could set on each section which list i wanted it to show on any page. That might tie in with what Norman has mentioned with regards to comparing variable contents. The second variable was just so that i did not have to have multiple hard coded product lists, so one could be dynamic etc.

                        It's been sometime but pretty sure it was something like:

                        What type of product is this - answer = your choices
                        What products do you want showing on this page - answer = mirror of your choices (used in productlist).

                        I could then create a brand page called Adidas for example, this then had a productlist that ran on products with adidas in as their type and the adidas brand page was told to only show adidas products by the what do you want showing variable. They have to be separate variables (i think) as you can have multi-brand sections.

                        Comment


                          #13
                          Here's how I'd go about this.

                          1) Create a Section level Variable: "Group", Type: List of Choices, Place of Setting Section and Product. Set the values (I'm using the Demo Site) to e.g. computing, photographic, entertainment, etc. Add an extra entry "dont show" and use this as the default value.

                          2) Create a Fragment level Variable: "GroupToShow", Type: List of Choices, Place of Setting: Fragment. Set the values to e.g. computing, photographic, entertainment, etc. I.e. same set of choices as above. Don't add the "dont show" entry.

                          Go to the Library / Layouts / Fragments, right-click any layout and choose Copy. Rename that copy to be Grouped Products List. Open Grouped Products List and replace all contents with:
                          Code:
                          <actinic:block php="true">
                          	$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" />
                          ENDOFLAYOUT;
                          				echo $productcode;
                          				}
                          		</actinic:block>
                          	</actinic:block>
                          </actinic:block>
                          That's coding done.

                          To use this:

                          For all Sections and products, set the Group variable as appropriate.

                          To display an "All computing" list, create a section e.g. All Computing.
                          Into it create one Fragment.
                          Set that Fragments layout to be Grouped Products List.
                          In Fragment Details / Properties, set GrouptoShow to "computing".

                          That's it.

                          Notes:

                          The if statement is designed to only show Products (no Duplicates or Fragments).

                          You can amend the line:

                          <actinic:variable name="ProductLayout" />

                          to use a more specific layout. E.g:

                          <actinic:variable name="ProductLayout" value="Standard Layout Using CSS" />

                          And V11 users might get best results from:

                          <actinic:variable name="ProductLayout" value="Product Summary" />

                          Where you'll be able to click the product name to get the full display page.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Good work Norman - the page is populated but the images throw out some interesting paths....

                            Actual Product Image Filename = 13645.jpg
                            Attempting to display from the PreviewHTML folder = products^45.jpg


                            Bikster
                            SellerDeck Designs and Responsive Themes

                            Comment


                              #15
                              Just uploaded to a server and the path to image becomes:

                              acatalog/images\products^45.jpg


                              Bikster
                              SellerDeck Designs and Responsive Themes

                              Comment

                              Working...
                              X