Announcement

Collapse
No announcement yet.

duplicate content - search engines - one solution

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

    duplicate content - search engines - one solution

    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
    Code:
    <link rel="canonical" href="http://www.myDomain.co.uk/acatalog/child-wheelchair-leg-cover.html">
    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:
    • 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";
    		}
    	}
    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:
    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 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.
    Code:
     <actinic:variable name="cusIncludeDetectDuplicateMetaTag" />
    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.
    Code:
     <!-- parent product was :k035: -->
     <link rel="canonical" href="http://www.myDomain.co.uk/acatalog/child-wheelchair-leg-cover.html">
    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

    #2
    Typo. You have cononical when you mean canonical.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Preview errors will hopefully go aweay if you change:
      Code:
      getDuplicateMetaTag("<actinic:variable name="CatalogURL" />", "<actinic:variable name="SectionID" />");
      To:
      Code:
      getDuplicateMetaTag("<actinic:variable name="CatalogURL" selectable="false" />", "<actinic:variable name="SectionID" selectable="false" />");
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks Norman, I've patched the original posting, sorry about the typo.
        Out of curiosity, why the selectable="false" attribute to the variable, whats it doing ??
        is it neccessary on all calls to PHP ? or under what circumstances do you use it.

        kev

        Comment


          #5
          Actinic variables have extra code around them when Previewing that allow them to be clickable in the Design Preview window.

          This code means that the variables break PHP expressions. Adding selectable="false" to the variable calls tells Actinic not to add the extra code and thus PHP sees what you expect.

          There is also another sub-field encoding="perl" which should be used if passing variable into PHP strings (our variable contains "Plenty O'Toole" in the following example). Use single quote syntax. E.g.

          $myvar = '<actinic:variable name="myvariable" selectable="false" />';

          If your variable happens to contain a single quote character then the PHP would look like:

          $myvar = 'Plenty O'Toole';

          Which will cause a syntax error.

          With encodng="perl" the expression looks like:

          $myvar = '<actinic:variable name="myvariable" encoding="perl" selectable="false" />';

          And your PHP will see:

          $myvar = 'Plenty O\'Toole';

          Which is a valid string.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Thanks Norman, you keep on learning

            Comment


              #7
              Hi
              we've been looking at sorting out duplicate pages and SEO issues. We're not v techie though - is your code here final? And will it work with v9 and v10 ?
              Nigel
              Actinic user with history
              www.nigelsecostore.com

              Comment


                #8
                just updated the code (hopefully correctly) to allow it to be used for any version from v8 onwards.

                Try the code Nigel, it works for us.

                kev

                Comment

                Working...
                X