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/

WordPress form manager set visitors email as sender

If you are using the plugin form-manager and you want to use the visitors email as sender in the header just follow these steps:

  1. Open up the wordpress admin panel
  2. Go to ”Forms”
  3. Click on your form
  4. Click on the tab ”Form extra”
  5. Type in the nickname ”email” nexto the field that holds the e-mail adress
  6. Save
  7. Go to the tab ”Edit”
  8. To the right under ”E-mail notification” change the field with the header ”from” to: [item email]
  9. Save
  10. Test

If you need any help, just leave a comment on this post and I will tell you how to fix it.

For more shortcodes, checkout the plugin-page: http://www.campbellhoffman.com/question/advanced-e-mail-settings/

Yii model default DB values

Great tip if your working with the PHP-framework Yii, if you create a new model and want to set some default values, like ”order by”, you can just add the following function (defaultScope) to your CActiveRecord extended class:

public function defaultScope(){
return array(
‘order’=>’my_order_field DESC’
);
}

Read more here: http://www.yiiframework.com/doc/guide/1.1/en/database.ar

Raspberry PI – disable screen saver for X

I just got my hands on a raspberry PI, and the first problem I ran into was that the screen is going black after a couple of minuts. It does not seems to be a simple way to solve this, but I found three solutions online and I will summon them up here. Just follow the steps in each:

X-Server setting:

  1. Run this to install utilities (if not installed): apt-get install x11-xserver-utils
  2. Create (if not exists) this file in your home directory: ~/.xinitrc
  3. Open thie file: sudo nano ~/.xinitrc
  4. Add the following four lines:
    xset s off
    xset -dpms
    xset s noblank
    exec /etc/alternatives/x-session-manager
  5. Save and exit

Lightdm setting:

  1. sudo nano /etc/lightdm/lightdm.conf
  2. In that file, look for: [SeatDefault]
  3. Insert this: xserver-command=X -s 0 dpms

KDB settings:

  1. Run: sudo nano /etc/kbd/config
  2. Change the value ”BLANK_TIME=30″ to ”BLANK_TIME=0″
  3. Change the value ”POWERDOWN_TIME=30″ to ”POWERDOWN_TIME=0″
  4. Save exit nano
  5. Run: sudo /etc/init.d/kbd restart

 

Completing all these steps solved the problem for me =)

WordPress (WP) wp_list_pages returns null

I recently had a problem with wordpress 3.6 and the function wp_list_pages within my template. I know my page had subpages, but when I executed the code the function returned NULL. After doing some digging I found that when wp_list_pages runs, it applys a ”exlcude”-filter, and somewhere on the way this filter added all my pages to it. I tried deactivating all plugins, search all code for the exclude filter funtion and tried another theme but it did not work.

So for now I just added comment marks infront of line 842 in fil ”wp-includes/post-template.php” which temporarly solved the problem.

I know this is the forbidden way so solve it =) so if someone has a better solution, please put it in the comment section.

WordPress child menu allways from top

<?php
/**
* Submenu
*/
if ($post->post_parent)    {
$ancestors=get_post_ancestors($post->ID);
$root=count($ancestors)-1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}
echo ”Parent: $parent”;
$children = wp_list_pages(‘title_li=&child_of=’.$parent.’&echo=0′);

if($children) { echo(‘<ul>’.$children.'</ul>’); }
?>

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

}
}

}