//
you're reading...

TYPO3

Typoscript XML Sitemap

Man kann sich mit Typoscript eine wunderbare XML Sitemap basteln, ohne dazu extra eine der vielen erhältlichen Extensions verwenden zu müssen.

In diesem Beispiel wird der komplette Seitenbaum abgebildet, plus zusätzlich die Einträge einer Extensiontabelle. Wenn man z.B. eine Auflistung von Newsartikeln inkl. einer Detailansicht zum jeweiligen Artikel hat, kann man diese Detailseiten ebenfalls hier hinzufügen. (ab 20 = CONTENT…)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
xmlSitemap = PAGE
xmlSitemap {
    typeNum = 200
    config {
        no_cache = 1
        disableAllHeaderCode = 1
        additionalHeaders = Content-Type: text/xml; charset=utf-8
        simulateStaticDocuments = 0
        baseURL = http://www.domain.at/
        absRefPrefix = http://www.domain.at/
        tx_realurl_enable = 1
    }
    10 = COA
    10 {
        wrap (
            <?xml version="1.0" encoding="UTF-8"?>
            |
        )
        10 = HMENU
        10 {
            special = directory
            #Ausgangspunkt / Root Seite
            special.value = 1
            #1 = Standard
            #2 = Erweitert
            #3 = Externe URL
            #4 = Shortcut
            #5 = Nicht im MenÃŒ
            #6 = Backend Benutzer Bereich
            #7 = Mount Seite
            #199 = Abstand
            #254 = Sysordner
            #255 = Recycler
            excludeDoktypes = 2,3,5,6,7,199,254,255
            1 = TMENU
            1 {
                expAll = 1
                NO {
                    doNotLinkIt = 1
                    stdWrap.cObject = COA
                    stdWrap.cObject {
                        wrap = |
                        10 = TEXT
                        10 {
                            typolink {
                                parameter.field = uid
                                returnLast = url
                            }
                            wrap = |
                        }
                        20 = TEXT
                        20 {
                            field = SYS_LASTCHANGED
                            strftime = %Y-%m-%dT%H:%M:%SZ
                            wrap = |
                        }
                        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
        }  
        20 = CONTENT
        20 {
            table = tx_meineextension_entries
            select {
                orderBy = title ASC
                languageField = sys_language_uid
                pidInList = 6,7,8
            }
            renderObj = COA
            renderObj {
                stdWrap.wrap = |
                5 = TEXT
                5 {
                    # Seite mit der Detailansicht
                    typolink.parameter = 10
                    typolink.additionalParams = &tx_meineextension_pi1[showUid]={field:uid}
                    typolink.additionalParams.insertData = 1
                    typolink.returnLast = url
                    wrap = |
                }
        10 = TEXT
                10 {
                    field = tstamp
                    strftime = %Y-%m-%dT%H:%M:%SZ
                    wrap = |
                }
                20 = TEXT
                20.value = <priority>0.4</priority><changefreq>weekly</changefreq>
            }
        }
    }
}

Ich denke das meiste ist selbsterklärend.

Die Ausgabe der Sitemap erhält man dann mittels der festgelegten Typenum. (http://www.domain.at/?type=200)
Mit der passenden realurl Config oder alternativ einer RewriteRule bekommt man das auch noch in schön hin:

PHP
1
2
3
4
5
6
7
8
9
//[...]
'fileName'=> array (
        'index'=> array (
            'sitemap.xml'=> array (
                'keyValues'=> array (
                    'type'=>200,
                ),
            ),
//[...]

(http://www.domain.at/sitemap.xml)

Discussion

No comments yet.

Post a Comment