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.

Allows you to create an online portfolio with TYPO3, whatever your medium Allows you to create item, client and category records. Item list and grid view can be filtered by Client/Tag/Category. All images can be created via GIFBUILDER Comes with 16 display modes - all record types come with a grid and list display mode Allowing you to work offline on your portfolio during a site redesign Shows statistics about your portfolio and gives you the ability to edit portfolio records en masse Many hooks exist allowing you to extend sb_portolio - this including adding new display modes Allow you to add your own content to sb_portfolio's output. Anything you can create in TypoScript can be added All records can be translated Inbuilt support for comments, ratings and pagebrowse extensions. Works with realurl/cooluri

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.

How To's

What's your opinion?

Do you have any comments about what you have read?

Let me know what you think!

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

SB Portfolio Extended

Demonstrates how to extend SB Portfolio using the hooks to add new markers and display modes. Not intended for production sites.

SB Portfolio SEO

Automatically adds metatags (description and keywords) as well as facebook supported Open Graph metatags.

Found a bug?

Report it here at the TYPO3 Forge.

Comments

There are none! Why not be the first?

Your Comment

All fields are required