My Sellerdeck Account | Free Trial

Sellerdeck Community & Knowledge Base

Go Back   Sellerdeck Community > Sellerdeck Ecommerce Software > Sellerdeck v9/v8

Search powered by Google
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 55 votes, 5.00 average. Display Modes
  #1  
Old 11-Sep-2007, 08:42 PM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 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 at 09:36 AM.. Reason: removed $flist = array(); becasue it was wasting memory.
Reply With Quote
  #2  
Old 12-Sep-2007, 07:49 AM
NormanRouxel's Avatar
NormanRouxel NormanRouxel is online now
Registered User
Join Date: Dec 2002
Full Name: Norman Rouxel
Posts: 10,814
Thanks: 9
Thanked 767 Times in 639 Posts
Those

$flist = array();

look redundant (probably from my earlier demo).
__________________
Norman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Reply With Quote
  #3  
Old 12-Sep-2007, 09:07 AM
dave_finlayson's Avatar
dave_finlayson dave_finlayson is offline
Registered User
Join Date: Sep 2004
Full Name: David Finlayson
Posts: 1,445
Thanks: 3
Thanked 5 Times in 5 Posts
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
Reply With Quote
  #4  
Old 12-Sep-2007, 09:14 AM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
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?
Reply With Quote
  #5  
Old 12-Sep-2007, 09:15 AM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
Quote:
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.
Reply With Quote
  #6  
Old 12-Sep-2007, 09:19 AM
dave_finlayson's Avatar
dave_finlayson dave_finlayson is offline
Registered User
Join Date: Sep 2004
Full Name: David Finlayson
Posts: 1,445
Thanks: 3
Thanked 5 Times in 5 Posts
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
Reply With Quote
  #7  
Old 12-Sep-2007, 09:22 AM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
no doubt, grand theft code is occuring right this second.
Reply With Quote
  #8  
Old 12-Sep-2007, 09:24 AM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
Quote:
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.
Reply With Quote
  #9  
Old 12-Sep-2007, 09:30 AM
george's Avatar
george george is offline
Registered User
Join Date: Aug 2003
Full Name: George Mackie
Posts: 2,958
Thanks: 1
Thanked 4 Times in 1 Post
Good work Gabriel, another seemingly basic tweak thats been needed for a long time.
__________________
Football Heaven

For all kinds of football souvenirs and memorabilia.
Reply With Quote
  #10  
Old 12-Sep-2007, 10:10 AM
NormanRouxel's Avatar
NormanRouxel NormanRouxel is online now
Registered User
Join Date: Dec 2002
Full Name: Norman Rouxel
Posts: 10,814
Thanks: 9
Thanked 767 Times in 639 Posts
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
Reply With Quote
  #11  
Old 12-Sep-2007, 11:13 AM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
sexy stuff.

mission complete!
Reply With Quote
  #12  
Old 12-Sep-2007, 11:27 AM
fergusw's Avatar
fergusw fergusw is offline
Registered User
Join Date: Mar 2004
Full Name: Fergus Weir
Posts: 1,584
Thanks: 75
Thanked 111 Times in 91 Posts
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*
Reply With Quote
  #13  
Old 12-Sep-2007, 12:32 PM
gabrielcrowe's Avatar
gabrielcrowe gabrielcrowe is offline
Registered User
Join Date: Sep 2004
Full Name: gabriel crowe
Posts: 2,886
Thanks: 8
Thanked 26 Times in 10 Posts
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?
Reply With Quote
  #14  
Old 12-Sep-2007, 01:27 PM
fergusw's Avatar
fergusw fergusw is offline
Registered User
Join Date: Mar 2004
Full Name: Fergus Weir
Posts: 1,584
Thanks: 75
Thanked 111 Times in 91 Posts
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
Reply With Quote
  #15  
Old 13-Sep-2007, 12:42 PM
fergusw's Avatar
fergusw fergusw is offline
Registered User
Join Date: Mar 2004
Full Name: Fergus Weir
Posts: 1,584
Thanks: 75
Thanked 111 Times in 91 Posts
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>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.