Rich Snippets in Content Pages

I get good search engine placement on the Content Pages that I write for my CS-Cart store. Adding the Rich Snippets to these pages so that the reviews and ratings my customers are providing on these pages gives them more visibility and brings more traffic.

Just like you would do with a blog.



I don't normally like changing CS-Cart templates, but I can't find a way to do this with my_changes and hooks so I just document my changes and hope for the best. Since v3 has all the updates it's going to get, it doesn't really matter anymore.



Version 3

To include AggregateRating data in your Content Pages do the following:

Edit \skins\customer\views\pages\view.tpl:

Change the entire contents to this:


```php



{$page.page}


{hook name="pages:page_content"}
{$page.description|unescape}
{/hook}
{capture name="mainbox_title"}{$page.page}{/capture}


{hook name="pages:page_extra"}
{/hook}
```

Edit \skins\black\customer\addons\discussion\views\discussion\view.tpl
Change line 22-23 FROM this:
```php {if $posts}
{include file="common_templates/pagination.tpl" id="pagination_contents_comments_`$object_id`" extra_url="&selected_section=discussion"}
```
Change TO this:
```php {if $posts}
{if $object_type == "A"}
{assign var="averagerating" value=$object_id|fn_get_average_rating:$object_type}
{assign var="ratingcount" value=$object_id|fn_get_rating_count:$object_type}






{/if}
{include file="common_templates/pagination.tpl" id="pagination_contents_comments_`$object_id`" extra_url="&selected_section=discussion"}
```

In HTML, inside the Description of your Content Pages, add any additional attributes you would like.
I suggest creating a Google+ account and including a byline with Author and Person like this:
```php


by YOUR NAME

```

And with a Google+ account, include a Publisher like this:
```php YOUR BUSINESS ```


To include Review data in the Snippets do the following. This will not be displayed by Google, but it's not an error:

Create file:
items_list_row.override.tpl

Contents of items_list_row.override.tpl:```php {if $object_type == "A"}



{$post.name|escape}
{$post.timestamp|date_format:"`$settings.Appearance.date_format`"}
{if $discussion.type == "R" || $discussion.type == "B"}

{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$post.rating_value|fn_get_discussion_rating}






{/if}
{if $discussion.type == "C" || $discussion.type == "B"}

{$post.message|escape|nl2br}

{/if}

{else}

{$post.name|escape}
{$post.timestamp|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}
{if $discussion.type == "R" || $discussion.type == "B"}


{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$post.rating_value|fn_get_discussion_rating}

{/if}


{if $discussion.type == "C" || $discussion.type == "B"}

{$post.message|escape|nl2br}

{/if}
{/if} ```

Place file in folder:
(create folder if necessary)
\skins\\customer\addons\my_changes\hooks\discussion\

Test it here:
http://www.google.com/webmasters/tools/richsnippets

This identifies your Content Pages as Articles and you enjoy all the attributes that articles have.

Next I'd like to work on identifying the News Posts as BlogPosts with Schema.org markup.

I forgot to mention the function for the $ratingcount:

fn_get_rating_count

If you are aggregating ratings for Snippets in products you probably already have a function for this, but earlier this year I made the following changes to the func.php script in \addons\discussion.



Change FROM this:

// Get thread average rating
//
function fn_get_average_rating($object_id, $object_type)
{
$discussion = fn_get_discussion($object_id, $object_type);
if (empty($discussion) || ($discussion['type'] != 'R' && $discussion['type'] != 'B')) {
return false;
}
return db_get_field("SELECT AVG(a.rating_value) as val FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $discussion['thread_id']);
}




Change TO this:

// Get thread average rating
//
function fn_get_average_rating($object_id, $object_type)
{
$discussion = fn_get_discussion($object_id, $object_type);
if (empty($discussion) || ($discussion['type'] != 'R' && $discussion['type'] != 'B')) {
return false;
}
return db_get_field("SELECT AVG(a.rating_value) as val FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $discussion['thread_id']);
}
// MAGPIE START
// Get thread rating count
function fn_get_rating_count($object_id, $object_type)
{
$discussion = fn_get_discussion($object_id, $object_type);
if (empty($discussion) || ($discussion['type'] != 'R' && $discussion['type'] != 'B')) {
return false;
}
return db_get_field("SELECT COUNT(*) as count FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $discussion['thread_id']);
}
// MAGPIE END

Nice one!

[quote name='Magpie Don' timestamp='1380066028' post='168683']

I get good search engine placement on the Content Pages that I write for my CS-Cart store. Adding the Rich Snippets to these pages so that the reviews and ratings my customers are providing on these pages gives them more visibility and brings more traffic.

Just like you would do with a blog.



I don't normally like changing CS-Cart templates, but I can't find a way to do this with my_changes and hooks so I just document my changes and hope for the best. Since v3 has all the updates it's going to get, it doesn't really matter anymore.



Version 3

To include AggregateRating data in your Content Pages do the following:

Edit \skins\customer\views\pages\view.tpl:

Change the entire contents to this:


```php



{$page.page}


{hook name="pages:page_content"}
{$page.description|unescape}
{/hook}
{capture name="mainbox_title"}{$page.page}{/capture}


{hook name="pages:page_extra"}
{/hook}
```

Edit \skins\black\customer\addons\discussion\views\discussion\view.tpl
Change line 22-23 FROM this:
```php {if $posts}
{include file="common_templates/pagination.tpl" id="pagination_contents_comments_`$object_id`" extra_url="&selected_section=discussion"}
```
Change TO this:
```php {if $posts}
{if $object_type == "A"}
{assign var="averagerating" value=$object_id|fn_get_average_rating:$object_type}
{assign var="ratingcount" value=$object_id|fn_get_rating_count:$object_type}






{/if}
{include file="common_templates/pagination.tpl" id="pagination_contents_comments_`$object_id`" extra_url="&selected_section=discussion"}
```

In HTML, inside the Description of your Content Pages, add any additional attributes you would like.
I suggest creating a Google+ account and including a byline with Author and Person like this:
```php


by YOUR NAME

```

And with a Google+ account, include a Publisher like this:
```php YOUR BUSINESS ```


To include Review data in the Snippets do the following. This will not be displayed by Google, but it's not an error:

Create file:
items_list_row.override.tpl

Contents of items_list_row.override.tpl:```php {if $object_type == "A"}



{$post.name|escape}
{$post.timestamp|date_format:"`$settings.Appearance.date_format`"}
{if $discussion.type == "R" || $discussion.type == "B"}

{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$post.rating_value|fn_get_discussion_rating}






{/if}
{if $discussion.type == "C" || $discussion.type == "B"}

{$post.message|escape|nl2br}

{/if}

{else}

{$post.name|escape}
{$post.timestamp|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}
{if $discussion.type == "R" || $discussion.type == "B"}


{include file="addons/discussion/views/discussion/components/stars.tpl" stars=$post.rating_value|fn_get_discussion_rating}

{/if}


{if $discussion.type == "C" || $discussion.type == "B"}

{$post.message|escape|nl2br}

{/if}
{/if} ```

Place file in folder:
(create folder if necessary)
\skins\\customer\addons\my_changes\hooks\discussion\

Test it here:
[url="http://www.google.com/webmasters/tools/richsnippets"]http://www.google.co...ls/richsnippets[/url]

This identifies your Content Pages as Articles and you enjoy all the attributes that articles have.

Next I'd like to work on identifying the News Posts as BlogPosts with Schema.org markup.
[/quote]
will you do this for 2.4.3. version?

hi

Does this change your code to version 4.2.2 is also applicable ØŸ