google / bing / msm and others marks down pages that are duplicates and gets confused which is the original page (ie the master), but if you put in a special metatag in the header, then the search engine understands this is a duplicates, points to the original and everything is ok.
the typical tag is
previous ideas within the forum had us keeping customVars to hold whether its a duplicate, I thought I would interogate the database directly, and automate the process.
this hack has been changed to allow v8+ actinic versions (to work automatically regardless of version)
and is also ONLY suitable for SINGLE PRODUCT PAGES, don't bother if you have multiple products on the page.
highlevel concept is as follows:
it involves PHP, so step 1, BACKUP, BACKUP, BACKUP
from v8 onwards, Actinic looks for a special file called siteincludes.php held in the current site directory. Any changes there are automatically available within the main actinic programme
heres the listing for my siteincludes.php
close actinic and re-open it, and siteincludes.php will be available to you to use within the layouts etc
now create a new layout called "cusIncludeDetectDuplicateMetaTag"
within that layout insert the following code:
now create a selector called "cusIncludeDetectDuplicateMetaTag" and make sure the only valid layout within the selector is the "cusIncludeDetectDuplicateMetaTag" one just created - the selector should ONLY be available at a "section" level
now include the following within the actual page layout that you use to list the duplicate product, up within the header area.
and save
now create a new sub-section within your pages and do all the normal things you do with that duplicate.
when you compile the page and preview it, it looks down the database, looks for a duplicate product, finds the original, gets the html page name and generates the correct metatag for you
example.
if you try looking at the source code of a page that is NOT a duplicate, these two lines are NOT included.
if you do not want the comment for "parent Product Code" to come out, just comment out that line within the php code.
If I have missed any bit of the concept, I'll correct it within the original posting.
the above code works fine on the finished page, but generates an error message in the preview panel within actinic, not really sure how to get rid of the message, as it clearly a red-herring - anyone got any ideas please
thanks Norman, code patched !
I've also patched (2011-06-11) the code to allow the code to be used in v8, v9, & v10 (I assume future code as well)
If I've made a mistake, sorry, I've only got v8 installed
the patch uses the phpVariable called $actinicVersion
Hope its useful to someone.
kev
the typical tag is
Code:
<link rel="canonical" href="http://www.myDomain.co.uk/acatalog/child-wheelchair-leg-cover.html">
this hack has been changed to allow v8+ actinic versions (to work automatically regardless of version)
and is also ONLY suitable for SINGLE PRODUCT PAGES, don't bother if you have multiple products on the page.
highlevel concept is as follows:
- detect the sectionID of the page
- look up all products that have this sectionID as its parent
- for each one, see if its a duplicate, else ignore
- if you find one, stop looking for any more
- lookup the html page name of the product you've duplicated
- insert a metatag in the correct format
- if non of the above conditions apply, don't bother outputting anything
it involves PHP, so step 1, BACKUP, BACKUP, BACKUP
from v8 onwards, Actinic looks for a special file called siteincludes.php held in the current site directory. Any changes there are automatically available within the main actinic programme
heres the listing for my siteincludes.php
Code:
function getOneUniqueField($fromTable, $where, $whereValue, $reqdField, $actinicVersion) { $whereValue = getSqlFormattedField($whereValue); $connect = $connect = odbc_pconnect("ActinicCatalog" . $actinicVersion,"",""); $query = "SELECT [".$reqdField."] FROM [".$fromTable."] WHERE [".$where."] = ".$whereValue; $result = odbc_exec($connect, $query); $resultValue=""; while(odbc_fetch_row($result)){ $resultValue = odbc_result($result, 1); } odbc_free_result($result); odbc_close_all(); return $resultValue; } function getSqlFormattedField($field) { if ($field =="") {return "";} if (is_numeric($field)==true) { return $field ; } $field = str_replace("{","",$field); // remove any "{" or "}" $field = str_replace("}","",$field); // "-" within the string makes msAccess think its a formula so // any "-" within the string needs to be replaced with '&chr(45)&' // and then finally put a ' at each end of the entire string // eg 123-abc-5678 becomes '1234'&Chr(45)&'abc'&Chr(45)&'5678' $hyphen = "-"; // hyphen within the product code $partsOfField = explode($hyphen, $field); $newProdCode = $partsOfField[0]; for($j = 1; $j < count($partsOfField); $j++){ $newProdCode = $newProdCode."'&Chr(45)&'".$partsOfField[$j]; } return "'".$newProdCode."'"; } function getHtmlNameOneProduct($ProductCode, $actinicVersion) { $nParentSectionID = getOneUniqueField('Product', 'Product Reference', $ProductCode, 'nParentSectionID', $actinicVersion); $ProductHtmlName = getOneUniqueField('Catalog section', 'nSectionID', $nParentSectionID, 'sPageName', $actinicVersion); return $ProductHtmlName; } function getDuplicateMetaTag($catalogURL, $sectionID, $actinicVersion) { $connect = $connect = odbc_pconnect("ActinicCatalog" . $actinicVersion,"",""); $query = "SELECT [sOriginalProdRef] FROM [Product] WHERE [nParentSectionID] = ".$sectionID; $result = odbc_exec($connect, $query); $mainParentProdCode=""; while(odbc_fetch_row($result)){ $mainParentProdCode = odbc_result($result, 1); if ($mainParentProdCode != "") {break;} // break out of the loop the moemnt you find ONE duplicate } odbc_free_result($result); odbc_close_all(); // if ( $mainParentProdCode != "" ) { $ProductHtmlName=getHtmlNameOneProduct($mainParentProdCode, $actinicVersion); echo "<!-- parent product was :".$mainParentProdCode.": -->\n"; echo "<link rel='canonical' href='".$catalogURL.$ProductHtmlName."' />\n"; } }
now create a new layout called "cusIncludeDetectDuplicateMetaTag"
within that layout insert the following code:
Code:
<actinic:block php="true"> getDuplicateMetaTag("<actinic:variable name="CatalogURL" selectable="false" />", "<actinic:variable name="SectionID" selectable="false" />", '<actinic:variable name="ECMajorVersion" selectable="false" />'); </actinic:block>
now include the following within the actual page layout that you use to list the duplicate product, up within the header area.
Code:
<actinic:variable name="cusIncludeDetectDuplicateMetaTag" />
now create a new sub-section within your pages and do all the normal things you do with that duplicate.
when you compile the page and preview it, it looks down the database, looks for a duplicate product, finds the original, gets the html page name and generates the correct metatag for you
example.
Code:
<!-- parent product was :k035: --> <link rel="canonical" href="http://www.myDomain.co.uk/acatalog/child-wheelchair-leg-cover.html">
if you do not want the comment for "parent Product Code" to come out, just comment out that line within the php code.
If I have missed any bit of the concept, I'll correct it within the original posting.
the above code works fine on the finished page, but generates an error message in the preview panel within actinic, not really sure how to get rid of the message, as it clearly a red-herring - anyone got any ideas please
thanks Norman, code patched !
I've also patched (2011-06-11) the code to allow the code to be used in v8, v9, & v10 (I assume future code as well)
If I've made a mistake, sorry, I've only got v8 installed
the patch uses the phpVariable called $actinicVersion
Hope its useful to someone.
kev
Comment