Template depending on right content

Submitting your vote...
Rating: 4.1 of 5. 9 vote(s).
Click the rating bar to rate this item.

Uses the 1. template if in the right column is some content else the 2. one.

 

temp.maintemplate= COA
temp.maintemplate {
  10 = COA
  10 {
    if.isTrue.numRows < styles.content.getRight
    10 = TEMPLATE
    10 {
       
      template = FILE
      template.file = fileadmin/templates/template-2column.html
    }
  }
  20 = COA
  20 {
    if.isFalse.numRows < styles.content.getRight
    10 = TEMPLATE
    10 {
       
      template = FILE
      template.file = fileadmin/templates/template.html
    }
  }
}


Comments


igor, 13-07-07 17:23:
This is exactly what I was looking for. Unfortunately it doesn't work though. It always shows the second template, the one defined in 20=COA ...
Igor, 13-07-07 17:54:
I got it to work. Found this on another site:
styles.content.get = CONTENT
styles.content.get {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
select.languageField = sys_language_uid
}

styles.content.getLeft < styles.content.get
styles.content.getLeft.select.where = colPos=1

styles.content.getRight < styles.content.get
styles.content.getRight.select.where = colPos=2

styles.content.getBorder < styles.content.get
styles.content.getBorder.select.where = colPos=3

I had to add this manually to the Typoscript and then it worked.
Tyler, 06-11-07 19:05:
If you also use css_styled_content (CSC) then you shouldn't need to use the second post by Igor.

Using CSC will have previously defined what each of the styles.content.get are.
sami, 02-09-08 09:39:
If you use automaketemplate:

temp.resource = COA
temp.resource {
10 = COA
10 {
if.isTrue.numRows < styles.content.getRight
10 = TEMPLATE
10 {

template = FILE
template.file = fileadmin/tmpl/tmpl01.html
}
}
20 = COA
20 {
if.isFalse.numRows < styles.content.getRight
10 = TEMPLATE
10 {

template = FILE
template.file = fileadmin/tmpl/tmpl02.html
}
}
}

### Configuration of the auto template parser: ###
plugin.tx_automaketemplate_pi1 {
content < temp.resource
Marijus, 15-10-08 11:58:
Beware of double-using the same if option. E.g. what I had was:

ifTrue.numRows < styles.content.getLeft
ifTrue.numRows < styles.content.getRight

and it ignores the first row. That's probably the expected behaviour but strange for a newbie like me.

The workaround was to use:

value = 0
ifGreaterThan.numRows < styles.content.getLeft
ifTrue.numRows < styles.content.getRight

(or .equals instead of repeated isFalse)
Norbert, 16-11-09 10:13:
Please help me with such a problem

I need to load CSS file according to different conditions

(if left and normal columns are not empty)
(if right and normal columns are not empty)
(if left and right and normal columns are not empty)

is it possible to make such complex conditions using typoscript?
Mikael, 17-10-11 08:43:
This Typoscript template wraps "normal" coloumn in different CSS ID:s depending on if there is content in Left and Right. There are four alternatives:
- Only normal coluomn
- Left and Normal
- Right and normal
- Left, Normal and Right

Normal coloumn resizes to fit in the area. CSS futher down.

lib.contentMain= COA
lib.contentMain{

# Wraps maincontent in CSS style "main_alt1" if there is content in Right but not in Left
10 = COA
10.wrap = <div id="main_alt1"> | </div>
10 {
if.isTrue.numRows < styles.content.getLeft
if.isFalse.numRows < styles.content.getRight
10 = CONTENT
10 < styles.content.get
}

# Wraps maincontent in CSS style "main_alt2" if there is content in Left but not in Right
20 = COA
20.wrap = <div id ="main_alt2"> | </div>
20 {
if.isTrue.numRows < styles.content.getRight
if.isFalse.numRows < styles.content.getLeft
10 = CONTENT
10 < styles.content.get
}

# Wraps maincontent in CSS style "main_alt3" if there is NO content in Right or Left.
30 = COA
30 {
if.isFalse.numRows < styles.content.getLeft
10 = COA
10.wrap = <div id="main_alt3"> | </div>
10 {
if.isFalse.numRows < styles.content.getRight
10 = CONTENT
10 < styles.content.get
}
}

# Wraps maincontent in CSS style "main_alt4" if there IS content in Right and Left.
40 = COA
40 {
if.isTrue.numRows < styles.content.getLeft
10 = COA
10.wrap = <div id="main_alt4"> | </div>
10 {
if.isTrue.numRows < styles.content.getRight
10 = CONTENT
10 < styles.content.get
}
}
}

Everything is wraped inside a div id="content" with a fixed width so the other content can float relative to it.

#content{
position: relative;
width: 900px;
margin-left: auto;
margin-right: auto;
}

#main_alt1{
width: 700px;
float: right;
}

#main_alt2{
width: 700px;
float: left;
}
#main_alt3{
clear: both;
}
#main_alt4{
width: 520px;
float: left;
margin-left: 6px;
}

#left{
float: left;
width: 180px;
}

#right{
float: right;
width: 180px;
}

#border{
border: 1px solid #444;
position: absolute;
top: 0px;
right: 0px;
}

Add comment

* - required field

*



*
*

Top 10 Updates

Contact us geändert am  21-Jul-2013 11:33:07
Contact us geändert am  21-Jul-2013 11:33:03
Useful Links geändert am  24-Apr-2013 08:31:20
Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17

Latest comments

25-Sep-2014 15:11:33
Javier Javier schrieb: My menu should be three pages with two cumlons in each of the 5 categories. I can't seem to print...
Graphical Menu
14-Mar-2014 15:53:15
Jesse Cain schrieb: I really like the backend of Typo3 and LDAP was easy and working great but I have checked what is...
My TYPO3 Page shows no content
11-Dec-2013 07:55:03
soma schrieb: Menu that recognizes when the user is on target page of the shortcut and wraps it with "active"...
External links and shortcuts directly in the menu
Deutsch
Search: