SEO Tips (Meta Tags)
SB Portfolio item content can be used to create meta tags quite easily all that's needed is a bit of experience with TypoScript.
Users of SB Portfolio 2.8.0+
You can install the extension SB Portfolio SEO to do everything that is documented on this page.
What advantages does the extension give you? Well, if you add new portfolios at different branches in your site you don't need to add all of the following information again for your new portfolio. Plus several new fields are created to add Social Media/Facebook metatags used when linking to your site.
Single Display Mode
Here is the TypoScript needed to add a meta tag and a meta description to the item Single display mode:
# Portfolio Single
[globalVar = TSFE:id = n]
page.meta.description >
page.meta.description.cObject = RECORDS
page.meta.description.cObject {
tables = tx_sbportfolio_items
source.data = GPvar:tx_sbportfolio_pi1|uid
source.intval = 1
conf.tx_sbportfolio_items = TEXT
conf.tx_sbportfolio_items {
field = summary
required = 1
}
}
page.meta.keywords >
page.meta.keywords = TEXT
page.meta.keywords.data = register:portTags
[global]
First, a TypoScript condition is used so that the above is only used on a page with Single display mode (change n in [globalVar = TSFE:id = n] to the page's uid).
Then any existing meta description is removed.
page.meta.description >
After this a RECORDS object is created which takes it's data from the URL variable tx_sbportfolio_pi1[uid]
source.data = GPvar:tx_sbportfolio_pi1|uid
The actual outputing of the RECORD will be a TEXT object, the information will come from the field summary.
conf.tx_sbportfolio_items = TEXT
conf.tx_sbportfolio_items {
field = summary
required = 1
field could equally be the item's fulldescription field, or any other for that mater, including any extra fields you may have created to extend sb_portfolio:
field = fulldescription
The keywords are obtained via a register that sb_portfolio sets - portTags holds the item's tags (this includes category tags):
page.meta.keywords >
page.meta.keywords = TEXT
page.meta.keywords.data = register:portTags
List and Grid Display Modes
Category Filtering
Similarly you can create meta tags for lists and grids. A TypoScript condition is used so that the following is only processed on a grid/list page when tx_sbportfolio_pi1[cat] is in the URL:
# Portfolio page with category filtering
[globalVar = TSFE:id = n] && [globalVar = GP:tx_sbportfolio_pi1|cat > 0]
page.meta.description >
page.meta.description.cObject = RECORDS
page.meta.description.cObject {
tables = tx_sbportfolio_categories
source.data = GPvar:tx_sbportfolio_pi1|cat
source.intval = 1
conf.tx_sbportfolio_categories = TEXT
conf.tx_sbportfolio_categories.field = description
conf.tx_sbportfolio_categories.required = 1
}
page.meta.keywords >
page.meta.keywords.cObject = RECORDS
page.meta.keywords.cObject {
tables = tx_sbportfolio_categories
source.data = GPvar:tx_sbportfolio_pi1|cat
source.intval = 1
conf.tx_sbportfolio_categories = TEXT
conf.tx_sbportfolio_categories.field = tags
conf.tx_sbportfolio_categories.required = 1
}
[global]
Again, any existing description is removed and a RECORDS object is created. The only difference this time is that the table has changed to tx_sbportfolio_categories and source.data is different. Any existing keywords are removed and the category's tags are set as keywords.
Client Filtering
Also very easy to implement, just changes in the condition and the table name. Also I combined several fields to make a more meaningful meta description:
# Portfolio page with client filtering
[globalVar = TSFE:id = n] && [globalVar = GP:tx_sbportfolio_pi1|clients > 0]
page.meta.description >
page.meta.description.cObject = COA
page.meta.description.cObject {
10 = RECORDS
10 {
tables = tx_sbportfolio_clients
source.data = GPvar:tx_sbportfolio_pi1|clients
source.intval = 1
conf.tx_sbportfolio_clients = TEXT
conf.tx_sbportfolio_clients.field = title
conf.tx_sbportfolio_clients.required = 1
conf.tx_sbportfolio_clients.noTrimWrap = |Portfolio items for: ||
}
20 = RECORDS
20 {
tables = tx_sbportfolio_clients
source.data = GPvar:tx_sbportfolio_pi1|clients
source.intval = 1
conf.tx_sbportfolio_clients = TEXT
conf.tx_sbportfolio_clients.field = description
conf.tx_sbportfolio_clients.required = 1
conf.tx_sbportfolio_clients.noTrimWrap = | - ||
}
}
[global]
Tag Filtering
This is the only tricky part because what appears in the query string is not an number value but an encoded text string. TypoScript conditions only allow for you to test get vars as >, < or =. Obviously, < and > won't work, and = would only suffice if you made a condition for every possible tag. To get around this problem you can use the userFunc condition. It returns either true or false, if true the condition is met and the following TS would be executed.
# Portfolio page with tag filtering
[globalVar = TSFE:id = n] && [userFunc = user_testGetValue(tag)]
page.meta.description >
page.meta.description.cObject = TEXT
page.meta.description.cObject {
dataWrap = Portfolio items tagged with '{GPvar:tx_sbportfolio_pi1|tag}'
htmlSpecialChars = 1
}
page.meta.keywords >
[global]
The actual user function code I use is (saved in a file called user_myConditionFuncs.php in typo3conf) :
<?php
function user_testGetValue($getVarReq) {
$result = false;
switch ($getVarReq) {
case 'tag':
if (t3lib_div::_GET('tx_sbportfolio_pi1')) {
$getVars = t3lib_div::_GET('tx_sbportfolio_pi1');
$getTag = $getVars['tag'];
if (!empty($getTag)) {
$result = true;
}
}
break;
}
return $result;
}
?>
case 'tag': is the word seen in the condition [userFunc = user_testGetValue(tag)] as and argument to the function. All the PHP does is check if the tag query string is there, if it is, true is returned.
In order to actually be usable, the above php file must be included, I added it to typo3conf/localconf.php thus:
require_once('user_myConditionFuncs.php');
Hopefully you can now create meta tags from you items/filtered lists.
Examples
Look at the source HTML from the following pages to see the effect the above TypoScripts have on the meta tags: description and keyword.
- http://www.bungert.co.uk/
Uses the page keywords and description - http://www.bungert.co.uk/en/portfolio/category/krautspotter.html
Uses the category's description and tags. - http://www.bungert.co.uk/en/portfolio/tag/Acrylic.html
Creates the description: "Portfolio items tagged with 'Acrylic'" and removes page keywords. - http://www.bungert.co.uk/en/portfolio/clients/ashley_cotter_cairns.html
Creates the description "Portfolio items for: Ashley Cotter-Cairns - A freelance Journalist, writer and Web Site author in Montreal, Canada." and removes page keywords.
If there was no description for the above client only the following would be used as the description meta tag: "Portfolio items for: Ashley Cotter-Cairns".
Above you can see the displayMode List, using the jQuery Galleria plugin.
See the TSRef for more information about creating RECORDS objects.
Support
If you have used sb_portfolio and want to show you appreciation feel free to donate to sb_portfolios development, or buy me something from my amazon wishlist.
Current Version
2.8.4
Extend SB Portfolio
Demonstrates how to extend SB Portfolio using the hooks to add new markers and display modes. Not intended for production sites.
Automatically adds metatags (description and keywords) as well as facebook supported Open Graph metatags.
Found a bug?
Report it here at the TYPO3 Forge.
There are none! Why not be the first?