Create a google sitemap with typoscript

Create a google sitemap with typoscript for pages and extensions

Use typoscript to create a sitemap with pages and custom urls from extensions, in this exemple I will include one of my one extensions:
xmlSitemap = PAGE
xmlSitemap {
typeNum = 200
config {
no_cache = 1
disableAllHeaderCode = 1
additionalHeaders = Content-Type: text/xml; charset=utf-8
simulateStaticDocuments = 0
absRefPrefix = http://www.YOUR-URL.com
tx_realurl_enable = 1
}

wrap (
<?xml version=”1.0″ encoding=”UTF-8″?>
<urlset xmlns=”http://www.google.com/schemas/sitemap/0.84&#8243;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xsi:schemaLocation=”http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd&#8221;
>|</urlset>
)

10 = HMENU
10 {
special = directory
special.value = 1

1 = TMENU
1 {
expAll = 1
NO {
doNotLinkIt = 1

stdWrap {

cObject = COA
cObject {

wrap = <url>|</url>

10 = TEXT
10 {
typolink {
parameter.field = uid
returnLast = url
}
wrap = <loc>|</loc>
}

20 = TEXT
20 {
field = SYS_LASTCHANGED
strftime = %Y-%m-%dT%H:%M:%SZ
wrap = <lastmod>|</lastmod>
}

30 = TEXT
30.value = <priority>1.0</priority>

if.isFalse.field = shortcut

}

}

}
}
2 < .1
2.NO.stdWrap.cObject.30.value = <priority>0.9</priority>
3 < .1
3.NO.stdWrap.cObject.30.value = <priority>0.8</priority>
4 < .1
4.NO.stdWrap.cObject.30.value = <priority>0.7</priority>
5 < .1
5.NO.stdWrap.cObject.30.value = <priority>0.6</priority>
6 < .1
6.NO.stdWrap.cObject.30.value = <priority>0.5</priority>
7 < .6
8 < .6
9 < .6
10 < .6
}

/**
* Render extension
*/
20 = CONTENT
20 {
table =  tx_txpremises_premises
select {
pidInList = 8 //– Page/folder ID
}
renderObj = COA
renderObj {
stdWrap.wrap = <url>|</url>
5 = TEXT
5 {
typolink.parameter = 9 //– Singel view page for your extension posts
typolink.additionalParams = &objectId={field:uid} //– Custom links to your extensions pages
typolink.additionalParams.insertData = 1
typolink.returnLast = url
wrap = <loc><![CDATA[|]]></loc> //– wrap URL with CDATA
}
10 = TEXT
10 {
field = tstamp
strftime = %Y-%m-%dT%H:%M:%SZ
wrap = <lastmod>|</lastmod>
}
20 = TEXT
20.value = <priority>0.7</priority><changefreq>weekly</changefreq>
}
}

}

This post is an extensions of http://www.adick.at/2010/06/01/typoscript-xml-sitemap/

TYPO3 social sharelinks with typoscript

Here is a ”simple” typoscript” to create sharelinks with just typoscript:

lib.field_footerleft = COA
lib.field_footerleft {
wrap = <div class="shareLinksfooter"><h3>Dela länkar</h3>|</div>

10 = TEXT
10.wrap = <p>|</p>
10 {
value = Facebook
typolink.title = Dela på Facebook
typolink.ATagParams = class=”facebooklink”
typolink.parameter.cObject = COA
typolink.parameter.cObject {
10 = TEXT
10.dataWrap = http://www.facebook.com/sharer.php?u={$baseURL}|
10.typolink.parameter.data = getenv:HTTP_HOST
10.typolink.returnLast = url
10.typolink.addQueryString = 1
10.typolink.addQueryString.exclude = id

20 = TEXT
20.data = getenv:REQUEST_URI

30 = TEXT
30.data = page:title
30.wrap = &t=|
30.rawUrlEncode = 1
}
}

20 = TEXT
20.wrap = <p>|</p>
20 {
value = Twitter
typolink.title = Dela på Twitter
typolink.ATagParams = class=”twitterlink”
typolink.parameter.cObject = COA
typolink.parameter.cObject {
10 = TEXT
10.data = getenv:HTTP_HOST
10.noTrimWrap = |Spana%20in%20||
10.dataWrap = http://twitter.com/home/?status=|
10.rawUrlEncode = 1

20 = TEXT
20.dataWrap = /|
20.typolink.parameter.data = TSFE:id
20.typolink.returnLast = url
20.typolink.addQueryString = 1
20.typolink.addQueryString.exclude = id
}
}

30 = TEXT
30.wrap = <p>|</p>
30 {
value = Google plus
typolink.title = Dela på Google plus
typolink.ATagParams = class=”googlepluslink”
typolink.parameter.cObject = COA
typolink.parameter.cObject {
10 = TEXT
10.dataWrap = https://plus.google.com/share?url={$baseURL}|
10.typolink.parameter.data = getenv:HTTP_HOST
10.typolink.returnLast = url
10.typolink.addQueryString = 1
10.typolink.addQueryString.exclude = id

20 = TEXT
20.data = getenv:REQUEST_URI

}
}

}

TYPO3 typoscript get last page updated

Use typoscript to fetch the latest updated page. This script fetch the last updated content and returns the date:

lib.field_lastupdated=CONTENT
lib.field_lastupdated {
table = tt_content
wrap =<p>Last update   |</p>
select{
orderBy = tstamp DESC
languageField=sys_language_uid
max = 1
pidInList = 1
recursive = 10
selectFields = tstamp
}
renderObj = COA
renderObj {
10 = TEXT
10 {
field = tstamp
strftime = %Y-%m-%d
wrap = |
}
}
}

Typoscript hmenu/tmenu has child

If you want to use a different wrap for your menu depending on if a page has childs or not. Just use ”IFSUB” in your typoscript.

Ex.) If you want to accomplish this:

<ul>
<li><a href=”#”>Start</a></li>
<li class=”haschilds”>Has submenu
<ul>
<li><a href=”#”>Subpage 1</a></li>
<li><a href=”#”>Subpage 2</a></li>
</ul>
</li>
<li><a href=”#”>No subpages</a></li>

Your typoscript should look like this:

lib.field_mainmenu = HMENU
lib.field_mainmenu {
1.entryLevel = 0
1.expAll = 1
1 = TMENU
1.wrap = <ul>|</ul>
1.noBlur = 0
1.ACT = 0
1.NO.wrapItemAndSub = <li>|</li>
1.IFSUB = 1
1.IFSUB.wrapItemAndSub = <li class=”haschilds”>|</li>
1.IFSUB.doNotLinkIt = 1

//– Wrap for Active link
1.ACT = 1
1.ACT.wrapItemAndSub = <li class=”selected”>|</li>
1.ACT.ATagParams = class=”selected”
1.ACTIFSUB = 1
1.ACTIFSUB.wrapItemAndSub = <li class=”haschilds”>|</li>
1.ACTIFSUB.doNotLinkIt = 1

//– Wrap for current link
1.CUR = 1
1.CUR.wrapItemAndSub = <li class=”selected”>|</li>
1.CUR.ATagParams = class=”selected”
1.CURIFSUB = 1
1.CURIFSUB.wrapItemAndSub = <li class=”haschilds”>|</li>
1.CURIFSUB.doNotLinkIt = 1

2 < .1
2.entryLevel = 1
2.wrap = <ul class=”submenu”>|</ul>

//– Deactivate wrap for Active link on sublevel
2.ACT = 0
2.CUR = 0

}

TYPO3 typoscript meta description & keywords with fallback

I use this typoscript for meta description and keywords when creating new websites.

//-- Meta description and keywords
page.meta.description.dataWrap = | {$plugin.meta.description}, {field:title}
page.meta.description.override.field = description
page.meta.keywords.dataWrap = | {$plugin.meta.keywords}, {field:title}
page.meta.keywords.override.field = keywords

//– Fallback to default values
page.meta.keywords.ifEmpty = YOUR fallback for keywords
page.meta.description.ifEmpty = YOUR fallback for description

This typoscript will set meta description/keywords from the fields in ”edit page” tab ”metadata”, and then add the page title to the end of both tags. If the fields are empty, it will fallback to ”YOUR fallback for description” and ”YOUR fallback för keywords”.

TYPO3 tt_news delete ”read more” from subheader

In the later versions of tt_news the ”read more” link is appended to the subheader via typoscript, which according to me is kind of annoying.

To solve this, just add this to you typoscript setup:

plugin.tt_news.displayList.subheader_stdWrap.append >

That will clear the subheader from the appended ”read more” link

Over and out

Typoscript add ”logout” link to main menu when someone is logged in

If you are using login pages with TYPO3, this is a great way to add a logout link to you current menu:


[usergroup=*]
lib.field_mainmenu.1.wrap = <ul> | <li><a href="?logintype=logout">Logout</a></li></ul>
[global]

Here is a complete menu example:


lib.field_mainmenu= HMENU
lib.field_mainmenu.entryLevel = 0
lib.field_mainmenu {
1 = TMENU
1.wrap = <ul> | </ul>
1 {
noBlur = 1
ACT = 0
}
//-- Wrap for normal link
1.NO {
wrapItemAndSub  =  <li>|</li>
}
//-- Wrap for Active link
1.ACT = 1
1.ACT.wrapItemAndSub = <li class="active">|</li>
1.ACT.ATagParams = class="active"
1.ACT.stdWrap.wrap =  <span class="selected">|</span>
//-- Wrap for current link
1.CUR = 1
1.CUR.wrapItemAndSub = <li class="active">|</li>
1.CUR.ATagParams = class="active"
1.CUR.stdWrap.wrap =  <span class="selected">|</span>
}

//-- If someone is logged in
[usergroup=*]
lib.field_mainmenu.1.wrap = <ul> | <li><a href="?logintype=logout">Logout</a></li></ul>
[global]