Announcement

Collapse
No announcement yet.

Bypassing cgi-bin links solution 2 - community collaboration.

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

  • NormanRouxel
    replied
    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.

    Leave a comment:


  • george
    replied
    Good work Gabriel, another seemingly basic tweak thats been needed for a long time.

    Leave a comment:


  • gabrielcrowe
    replied
    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.

    Leave a comment:


  • gabrielcrowe
    replied
    no doubt, grand theft code is occuring right this second.

    Leave a comment:


  • dave_finlayson
    replied
    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!

    Leave a comment:


  • gabrielcrowe
    replied
    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.

    Leave a comment:


  • gabrielcrowe
    replied
    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?

    Leave a comment:


  • dave_finlayson
    replied
    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.

    Leave a comment:


  • NormanRouxel
    replied
    Those

    $flist = array();

    look redundant (probably from my earlier demo).

    Leave a comment:


  • 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.
Working...
X