Announcement

Collapse
No announcement yet.

Bypassing cgi-bin links solution 2 - community collaboration.

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

    #16
    Needs testing
    this, is my favourite phrase. its a shame more people dont test as much as you mr fergus.

    Comment


      #17
      is there an odbc function that counts rows? do you really have to page through the results?

      Comment


        #18
        PHP Code:
        odbc_num_rows 
        would be the one you mean, however for MS Access it returns -1
        Fergus Weir - teclan ltd
        Ecommerce Digital Marketing

        SellerDeck Responsive Web Design

        SellerDeck Hosting
        SellerDeck Digital Marketing

        Comment


          #19
          well, isnt that just crap-tacular.

          Comment


            #20
            Fergus,

            You may need some extra conditions to make sure that the Duplicate isn't deleted.

            Also, are you seeing the occassional crash when exiting Actinic that Gabriel and I saw when doing this sort of ODBC stuff.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #21
              Good point Norman. I have edited original post to add an additional function for returning number of products 'excluding' the deleted duplicates.

              Regarding occasional crashes..... I've not noticed any yet! I see memory error warning and crash upon opening if I have any incorrect syntax in the actinic_main.php file, but not upon exit.... yet!
              Fergus Weir - teclan ltd
              Ecommerce Digital Marketing

              SellerDeck Responsive Web Design

              SellerDeck Hosting
              SellerDeck Digital Marketing

              Comment


                #22
                Has anyone or is anyone still using this, something that was on my to do list and is still on my to do list.

                If so is there anything i need to watch out for, mind you my actinic_main.php is ermm a little different to the original lol, get all fat and juicy

                D

                Comment


                  #23
                  i still am, on every site i make.

                  i have found it stable, and fast.

                  in particular, i have just added another addition to the php menu builder, that also uses flat filenames, instead of cgi-bin numbers.

                  much better for seo.

                  Comment


                    #24
                    Not sure if I should have started a new thread in the v9 section, but here goes...

                    Has anyone managed to get this working with v9.03?

                    When I try it I get the following error after uploading.

                    You don't have permission to access /acatalog/Fatal error: Call to undefined function Ref2file() in main on line 1 on this server.
                    I presume it's something to do with actinic_main.php being different
                    Unusual Silver Jewellery
                    Giftmill - Unusual Gifts
                    Crystal Healing Jewellery
                    Steampunk Jewellery

                    Comment


                      #25
                      this works in all versions of actinic to date. its running on loads of catalogs i'v built.

                      instead of putting it in an external file, try including it in a template, and including it in the header of your pages.

                      wrap each function in:

                      PHP Code:
                      if (!function_exists('myfunc')) {

                      function 
                      myfunc(){
                      // your function here
                      }


                      to avoid errors.

                      Comment


                        #26
                        Still no joy

                        I have removed the extra code from Actinic_main.php

                        I created a new layout called PHPStuff and added the following code

                        Code:
                        if (!function_exists('GetSectFileName')) {
                        
                        /***************************************************************
                        * 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($result, 1);  
                                }
                                odbc_close($connect);
                                    return $url;
                            }
                        }
                        
                        if (!function_exists('GetProdParent')) {
                        
                        /***************************************************************
                        * 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($result, 1);
                                }
                                odbc_close($connect);
                                    return $parentid;
                        
                                }
                        	}
                        
                        if (!function_exists('GetSectParent')) {
                        
                        /***************************************************************
                        * 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($result, 1);
                                }
                                odbc_close($connect);
                                    return $parentid;
                                }
                        }
                        if (!function_exists('Ref2File')) {
                        
                        /***************************************************************
                        * 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));
                        }
                        }
                        
                        if (!function_exists('Ref2ParentFile')) {
                        
                        function Ref2ParentFile($ref) {
                        return GetSectFileName(GetSectParent(GetProdParent($ref)));
                        }
                        }
                        I then inserted the PHPStuff layout into the head section. This caused all sorts of warnings so I wrapped it in a block with PHP=True and Selectable=False which stopped the errors.

                        I then used the following in a marketing list

                        Code:
                        <a href="<actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>">Link Text</a>
                        After uploading and clicking on the Link Text I still get the following error

                        Code:
                        Forbidden
                        You don't have permission to access /acatalog/Fatal error: Call to undefined function Ref2file() in main on line 1 on this server.
                        Any more pointers to help a numpty understand?
                        Unusual Silver Jewellery
                        Giftmill - Unusual Gifts
                        Crystal Healing Jewellery
                        Steampunk Jewellery

                        Comment


                          #27
                          You have to close and restart Actinic after making any changes to actinic_main.php.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #28
                            I have tried that Norman.

                            Just to make sure - it is Actinic_Main.php in the program files folder rather than anywhere else?
                            Unusual Silver Jewellery
                            Giftmill - Unusual Gifts
                            Crystal Healing Jewellery
                            Steampunk Jewellery

                            Comment


                              #29
                              it is Actinic_Main.php in the program files folder rather than anywhere else
                              That's right.
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment


                                #30
                                Some progress made

                                I've got rid of all the errors and can get Ref2ParentFile to work.
                                The same can't be said of Ref2File which just appears to be empty - I have placed it outside of the href to confirm the result of this function is blank.

                                Here is my code to date:-

                                Code:
                                <actinic:block php="true" >
                                	
                                
                                if (!function_exists('GetSectFileName')) {
                                
                                /***************************************************************
                                * GetSectFileName - A support function for Ref2File
                                ***************************************************************/
                                
                                function GetSectFileName($sectref)
                                    {
                                        $connect = odbc_connect("ActinicCatalog9","","");
                                        $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($result, 1);  
                                        }
                                        odbc_close($connect);
                                            return $url;
                                    }
                                }
                                
                                if (!function_exists('GetProdParent')) {
                                
                                /***************************************************************
                                * GetProdParent - A support function for Ref2File
                                ***************************************************************/
                                function GetProdParent($prodrefs)
                                    {
                                    $prodrefs = str_replace("{","",$prodrefs);
                                    $prodrefs = str_replace("}","",$prodrefs);
                                        $connect = odbc_connect("ActinicCatalog9","","");
                                        $query = "SELECT [nParentSectionID] FROM [product] WHERE [Product Reference]='".$prodrefs."'";
                                        $result = odbc_exec($connect, $query);
                                        while(odbc_fetch_row($result)){
                                            $parentid = odbc_result($result, 1);
                                        }
                                        odbc_close($connect);
                                            return $parentid;
                                
                                        }
                                }
                                
                                if (!function_exists('GetSectParent')) {
                                
                                /***************************************************************
                                * GetSectParent- A support function for Ref2File
                                ***************************************************************/
                                function GetSectParent($sectrefs)
                                    {
                                    $prodrefs = str_replace("{","",$sectrefs);
                                    $prodrefs = str_replace("}","",$sectrefs);
                                        $connect = odbc_connect("ActinicCatalog9","","");
                                        $query = "SELECT [nParentSectionID] FROM [Catalog section] WHERE [nSectionID]=".$sectrefs."";
                                        $result = odbc_exec($connect, $query);
                                        while(odbc_fetch_row($result)){
                                            $parentid = odbc_result($result, 1);
                                        }
                                        odbc_close($connect);
                                            return $parentid;
                                        }
                                }
                                if (!function_exists('Ref2File')) {
                                            
                                function Ref2File($ref) {
                                return GetSectFileName(GetProdParent($ref));
                                }
                                }
                                
                                if (!function_exists('Ref2ParentFile')) {
                                
                                function Ref2ParentFile($ref) {
                                return GetSectFileName(GetSectParent(GetProdParent($ref)));
                                }
                                }
                                </actinic:block>
                                This is in a layout placed in the head section as before

                                This is what I have in the mini related product layout

                                Code:
                                <a href="<actinic:variable name="CatalogURL" /><actinic:block php="true">echo Ref2file("<actinic:variable Name="ProductReference" />");</actinic:block>">Link Text</a>
                                Any further ideas?
                                Unusual Silver Jewellery
                                Giftmill - Unusual Gifts
                                Crystal Healing Jewellery
                                Steampunk Jewellery

                                Comment

                                Working...
                                X