include this code at the end of your actinic_main.php then restart actinic.
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:
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.
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($result, 1);
}
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($result, 1);
}
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($result, 1);
}
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>
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>
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.
Comment