<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TYPO3-Addict &#187; Conditions</title>
	<atom:link href="http://www.typo3-addict.com/tag/conditions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.typo3-addict.com</link>
	<description>For those addicted to TYPO3</description>
	<lastBuildDate>Wed, 02 Jun 2010 13:03:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>TYPO3: How to use TypoScript Conditions</title>
		<link>http://www.typo3-addict.com/2009/11/typo3-how-to-use-typoscript-conditions/</link>
		<comments>http://www.typo3-addict.com/2009/11/typo3-how-to-use-typoscript-conditions/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 10:10:23 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Conditions]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Typoscript]]></category>

		<guid isPermaLink="false">http://www.typo3-addict.com/?p=828</guid>
		<description><![CDATA[A TypoScript condition is a powerful and easy way of telling TYPO3 when to execute a piece of TypoScript. In this tutorial I&#8217;ll explain the basics of such a condition and how to use one. Conditions are very similar to a PHP if-statement and should be easy to use if you understand the principles of [...]]]></description>
			<content:encoded><![CDATA[<p>A TypoScript condition is a powerful and easy way of telling TYPO3 when to execute a piece of TypoScript. In this tutorial I&#8217;ll explain the basics of such a condition and how to use one. Conditions are very similar to a PHP if-statement and should be easy to use if you understand the principles of PHP if, elseif and else.</p>
<p><span id="more-828"></span>A condition always consists of 2 brackets with a statement in the middle:</p>
<pre>[your-statement]</pre>
<p>Multiple conditions can be combined by using so called operators: &amp;&amp; (AND) or || (OR), if no operator is defined the default will be OR.</p>
<p>Example 1: Load ie.css only when the browser is IE</p>
<pre>[browser = msie]
page.includeCSS {
   1 = fileadmin/ie.css
}
[end]</pre>
<p>Example 2: Load ie6.css only when the browser is IE and the version is lower than 7</p>
<pre>[browser = msie] &amp;&amp; [version = &lt;7]
page.includeCSS {
   1 = fileadmin/ie6.css
}
[end]</pre>
<p>Example 3: Load ie stylesheet when the browser is IE, load normal stylesheet with all other browsers</p>
<pre>[browser = msie] &amp;&amp; [version = &lt;7]
page.includeCSS {
   1 = fileadmin/ie.css
}
[else]
page.includeCSS {
   1 = fileadmin/style.css
}
[end]</pre>
<p>Example 4: Use the time to accordingly greet your visitor</p>
<pre># Display 'Good Morning before 12 o'clock
[hour =&lt; 12]
lib.greeting = TEXT
lib.greeting {
    value = Good Morning!
}
[else]
# Display 'Good Day' after 12 o'clock
lib.greeting = TEXT
lib.greeting {
    value = Good Day!
}
[end]</pre>
<p>Let&#8217;s make things a little bit more interesting.</p>
<p>Example 5: We want to include some records (from page id 250) in our left_column div but only on page id 100 or a subpage of this page!</p>
<pre># First we define the content of the 'left_column' div:
left_column = COA
left_column {
   10 &lt; lib.regularContent
   20 &lt; lib.specialContent
}

# Display the lib.specialContent only on page id 100 or a subpage
[PIDinRootline = 100]
lib.specialContent = CONTENT
lib.specialContent {
   table = tt_content
   select {
      pidInList = 250
      orderBy = sorting
      languageField = sys_language_uid
   }
}
[end]</pre>
<p>I could make a hundred examples but when you know to basics it isn&#8217;t that hard. If you want to know more about these conditions please read chapter 4 of the TSRef:<br />
<a title="TypoScript Conditions" href="http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/4/1/">http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/4/1/</a></p>
<p>If you have any questions don&#8217;t hesitate to ask!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.typo3-addict.com/2009/11/typo3-how-to-use-typoscript-conditions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
