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

}
}

}

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 conditional typoscript if iPhone

If you want conditional typoscript depending on browser (for example iPhone), just use this typoscript in the setup part of your template:

[useragent = *iPhone*]

//– Insert your iPhone additional typoscript here

[end]

You can also use an [else] statement if you want, then it should look like this:

[useragent = *iPhone*]

//– Insert your iPhone additional typoscript here

[else]

//– Insert your regular typoscript here

[end]

TYPO3/typoscript render only content

If you want to render just the content elements of a TYPO3 page, create an extension template an insert this typoscript code in the ”setup” part of the template:


config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}

This will prevent all other HTML-code from being renderd. This will be useful if you want to use Ajax-calls. You can also combine this with a typenum if you want to be able to render the page both as full HTML page and Ajax page. Example below with the use of templavoilá:


ajaxCall = PAGE
ajaxCall {
typeNum = 4000
10 = USER
10.userFunc = tx_templavoila_pi1->main_page
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}
}