Needs testing
Announcement
Collapse
No announcement yet.
Bypassing cgi-bin links solution 2 - community collaboration.
Collapse
X
-
PHP Code:odbc_num_rows
Fergus Weir - teclan ltd
Ecommerce Digital Marketing
SellerDeck Responsive Web Design
SellerDeck Hosting
SellerDeck Digital Marketing
Comment
-
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
-
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
-
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.
Comment
-
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
}
}
Comment
-
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 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>
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.
Comment
-
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
-
it is Actinic_Main.php in the program files folder rather than anywhere elseNorman - www.drillpine.biz
Edinburgh, U K / Bitez, Turkey
Comment
-
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 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>
Comment
Comment