Announcement

Collapse
No announcement yet.

Bypassing cgi-bin links solution 2 - community collaboration.

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

    Bypassing cgi-bin links solution 2 - community collaboration.

    include this code at the end of your actinic_main.php then restart actinic.

    PHP Code:
    /***************************************************************
    * GetSectFileName - A support function for Ref2File
    ***************************************************************/

    function GetSectFileName($sectref)
        {
            
    $connect odbc_connect("ActinicCatalog8","","");
            
    $query "SELECT [sPageName] FROM [Catalog Section] WHERE [nSectionID]=".$sectref."";
            
    $result odbc_exec($connect$query);
            while(
    odbc_fetch_row($result)){
                
    //$name = odbc_result($result, 2);
                
    $url odbc_result($result1);  
            }
            
    odbc_close($connect);
                return 
    $url;
        }

    /***************************************************************
    * GetProdParent - A support function for Ref2File
    ***************************************************************/
    function GetProdParent($prodrefs)
        {
        
    $prodrefs str_replace("{","",$prodrefs);
        
    $prodrefs str_replace("}","",$prodrefs);
            
    $connect odbc_connect("ActinicCatalog8","","");
            
    $query "SELECT [nParentSectionID] FROM [product] WHERE [Product Reference]='".$prodrefs."'";
            
    $result odbc_exec($connect$query);
            while(
    odbc_fetch_row($result)){
                
    $parentid odbc_result($result1);
            }
            
    odbc_close($connect);
                return 
    $parentid;

            }

    /***************************************************************
    * GetSectParent- A support function for Ref2File
    ***************************************************************/
    function GetSectParent($sectrefs)
        {
        
    $prodrefs str_replace("{","",$sectrefs);
        
    $prodrefs str_replace("}","",$sectrefs);
            
    $connect odbc_connect("ActinicCatalog8","","");
            
    $query "SELECT [nParentSectionID] FROM [Catalog section] WHERE [nSectionID]=".$sectrefs."";
            
    $result odbc_exec($connect$query);
            while(
    odbc_fetch_row($result)){
                
    $parentid odbc_result($result1);
            }
            
    odbc_close($connect);
                return 
    $parentid;
            }

    /***************************************************************
    * Ref2file - Use Actinic's pwn database, to convert a prod ref, to a filename
    * @param int $ref the product reference.
    * @author Gabriel Crowe + NormanRouxel 08 September 2007
    *
    * usage example:
    <a href="<actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>">Link Text</a>
    ***************************************************************/
                
    function Ref2File($ref) {
    return 
    GetSectFileName(GetProdParent($ref));
    }
    function 
    Ref2ParentFile($ref) {
    return 
    GetSectFileName(GetSectParent(GetProdParent($ref)));

    HTML Code:
    <a href="<actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>">Link Text</a>
    then make a link like this, wherever a product reference is in context, such as a marketing item.

    To get the parent of the section your item is in (for single product per page lists) then make a link like this:
    HTML Code:
    <a href="<actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2ParentFile("<actinic:variable Name="ProductReference" />");</actinic:block>">Link Text</a>
    This will traverse up another level.


    what does the code do? basically, it uses actinics own database to find the name of the section that pertains to a product. by using the product reference. The code may cause some slowdown on larger shops, but really, all it does is convert the prodref, to the filename online.

    note:
    **EXPERIMENTAL** causes some errors occasionally when actinic closes. Other than that, how about some testing and input?

    special thanks go to NormanRouxel for the initial code.
    Last edited by gabrielcrowe; 12-Sep-2007, 09:36 AM. Reason: removed $flist = array(); becasue it was wasting memory.

    #2
    Those

    $flist = array();

    look redundant (probably from my earlier demo).
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Gabe,

      Seems to work pretty well, generated all the links correctly anyway.

      Couple of wee probs:-

      We display 10 best sellers, adding it into the standard best seller layout works online but within Actinic it only displays half it should (i.e 5 best sellers)

      Adding it to Also bought's also works but I can't get it to display images within Actinic, although again, they are displayed online.
      Cheers

      David
      Located in Edinburgh UK

      http://twitter.com/mcfinster

      Comment


        #4
        norm, you're spot on. lol.

        in fact, i had to move the echoing into the loop, since actinic had a paddy over something about the structure it generated.

        its so fiddly sometimes. not what i'd call stable at all.

        and as for the bugs there, you're right too, its far from productionable.

        has anyone any ideas why this happens?

        Comment


          #5
          Originally posted by dave_finlayson
          Gabe,

          Seems to work pretty well, generated all the links correctly anyway.

          Couple of wee probs:-

          We display 10 best sellers, adding it into the standard best seller layout works online but within Actinic it only displays half it should (i.e 5 best sellers)

          Adding it to Also bought's also works but I can't get it to display images within Actinic, although again, they are displayed online.
          these problems are due to the piddly poor preview rendering. I generally have it turned off, since i trust my instinct more than i trust the incomplete render of the preview.

          generated pages look ok, as you say, so once uploaded, the site looks and works fine.

          Comment


            #6
            Yep, so far I haven't found any other issues, great work.

            Now that you've proved it works, we just need Actinic to pop it into v9!
            Cheers

            David
            Located in Edinburgh UK

            http://twitter.com/mcfinster

            Comment


              #7
              no doubt, grand theft code is occuring right this second.

              Comment


                #8
                Originally posted by NormanRouxel
                Those

                $flist = array();

                look redundant (probably from my earlier demo).
                actually, i left these in as a thankyou. so people would know that this is actually your code.

                of course! lolz.

                Comment


                  #9
                  Good work Gabriel, another seemingly basic tweak thats been needed for a long time.
                  Football Heaven

                  For all kinds of football souvenirs and memorabilia.

                  Comment


                    #10
                    Why not put the bit
                    Code:
                    <actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>
                    into a new Layout (DirectProductLink) as below

                    Code:
                    <actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>#<actinic:variable Name="EncodedProductAnchor" />
                    And you then make links like this

                    Code:
                    <a href="<actinic:variable Name="DirectProductLink" />">My link text</a>
                    Which is a little more readable.

                    I've also added in the product anchor so you'll go straight to the actual product on long pages.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      sexy stuff.

                      mission complete!

                      Comment


                        #12
                        Ok - thinking aloud here......

                        Could this method not also be used for generating navigation structures.
                        I'm thinking of a way to generate section/sub-section flyout or expanded menu dynamically allowing for different section structures on each page without oodles of blockifs.

                        All you require is a the PHP query to the database to return relevant sections/section HTML filenames into a nice <ul><li> structure and voila.....

                        e.g. each sub-section you go into could simply have the menu showing the expanded/exploded section that you are currently in.
                        This would eliminate any javascript overhead, and allow for reduced HTML overhead, especially on large sites.

                        *stops thinking out loud*
                        Fergus Weir - teclan ltd
                        Ecommerce Digital Marketing

                        SellerDeck Responsive Web Design

                        SellerDeck Hosting
                        SellerDeck Digital Marketing

                        Comment


                          #13
                          done that.

                          it can generate happy links from any section. and it has concept of what section you are in. it lets you generate child sections in the tree as deep as you request. it makes any structure, ul/li, dt/dl/dd, div/a. its really very easy to make a single thingybob that makes tabs, lists, flyouts etc etc.

                          its not really postable.

                          i'd like norman to explore this. i dont want to offend him by releasing code that trumps his collapso. to this end, since he started the code off in my head, i'll be sending what i've done to him.

                          is that ok norm?

                          Comment


                            #14
                            At least this post is here with confirmation of possible solutions to people's problems, and if Norm argees, then people can be directed to Drillpine for the donationware code solutions!

                            I'll see what other uses and functionality I can think up in the meantime
                            Fergus Weir - teclan ltd
                            Ecommerce Digital Marketing

                            SellerDeck Responsive Web Design

                            SellerDeck Hosting
                            SellerDeck Digital Marketing

                            Comment


                              #15
                              OK - another application:

                              Return a value if a product HAS duplicates:
                              PHP Code:
                              /************************************************************************
                              * DoesProdHaveDuplicates - Returns  a yes/no value if a product 
                              * has  one or more duplicates
                              * @param $prodid   - ProductID from Actinic

                              * Usage example:
                              Has a duplicate?: <actinic:block php="true">echo DoesProdHaveDuplicates("<actinic:variable name="ProductID" />");</actinic:block>
                              *************************************************************************/
                              function DoesProdHaveDuplicates($prodid)
                                  {
                                  
                              $prodid str_replace("{","",$prodid);
                                  
                              $prodid str_replace("}","",$prodid);
                                  
                              $blreturn 'no';
                                      
                              $connect odbc_connect("ActinicCatalog8","","");
                                      
                              $query "SELECT [nParentSectionID] FROM [product] WHERE [sOriginalProdRef] = '".$prodid."'";
                                      
                              $result odbc_exec($connect$query);
                                      
                                      
                              $count=0;
                                      while(
                              $temp odbc_fetch_into($result,&$counter)){
                                          
                              $count++;
                                      }
                                      if (
                              $count 0) {
                                          
                              $blreturn 'yes';
                                          }

                                      
                              odbc_close($connect);
                                      
                                      return 
                              $blreturn;
                                      } 
                              and implementing on page with:
                              Code:
                              Has a duplicate: <actinic:block php="true">echo DoesProdHaveDuplicates("<actinic:variable name="ProductID" />");</actinic:block>
                              This could be brought into a condition as Norman has indicated above.

                              Needs testing

                              [edit - to add another coding to check for deleted product duplicates. Also returns number of duplicates]

                              PHP Code:
                              function DoesProdHaveDuplicatesNoDeleted($prodid)
                                  {
                                  
                              $prodid str_replace("{","",$prodid);
                                  
                              $prodid str_replace("}","",$prodid);
                                      
                              $connect odbc_connect("ActinicCatalog8","","");
                                      
                              $query "SELECT [nParentSectionID] FROM [product] WHERE Status = 'N' AND [sOriginalProdRef] = '".$prodid."'";
                                      
                              $result odbc_exec($connect$query);
                                      
                                      
                              $count=0;
                                      while(
                              $temp odbc_fetch_into($result,&$counter)){
                                          
                              $count++;
                                      }

                                      
                              odbc_close($connect);
                                      
                                      return 
                              $count;
                                      } 
                              usage:
                              Code:
                              Duplicates: <actinic:block php="true">echo DoesProdHaveDuplicatesNoDeleted("<actinic:variable name="ProductID" />");</actinic:block>
                              Fergus Weir - teclan ltd
                              Ecommerce Digital Marketing

                              SellerDeck Responsive Web Design

                              SellerDeck Hosting
                              SellerDeck Digital Marketing

                              Comment

                              Working...
                              X