Zum Inhalt springen

statischer Text (globaler Text) sprachabhängig

Erstellt am 6. Februar 2007 · 2 Antworten · letzte Antwort am 6. Februar 2007

Tags: Templates & Layouts, Frage

hombo13 ·

Hallo Forum, ich möchte mit Hilfe von "automaketemplate" in einem klassischen 3-Spaltenlayout auf der rechten Spalte statischen Text (globaler Text) anfügen. Auf jeder Seite wird der gleich Text ausgegeben - z.B. für News, Rechtlicher Hinweis, CopyLeft usw...
Den statischen Text (sieh "content_r_statisch" im nachfolgenden Codebeispiel) wird im temp.main.Template normal eingebunden. Das funktioniert auch gut so. Hier der Code:

temp.mainTemplate = TEMPLATE
temp.mainTemplate {
	# Feeding the content from the Auto-parser to the TEMPLATE cObject:
    	template =< plugin.tx_automaketemplate_pi1
    	# Select only the content between the <body>-tags
    	workOnSubpart = DOCUMENT_BODY
    	subparts.menu_1 < temp.menu_1
        subparts.content < styles.content.get
    	subparts.col_rechts < styles.content.getRight
    	subparts.subnavigation < temp.subnavigation
    	subparts.wo < temp.wo
      	#HIER KÖNNEN WIR WEITERE SUBPARTS ANFÜGEN
      	#SPRACHWECHSLER
      	subparts.sprache_F = TEXT
	subparts.sprache_F {
           field = uid
           wrap = | <a href="index.php?id=|&L=1" title="Version Français">F / </a> 
           }
	subparts.sprache_D = TEXT
	subparts.sprache_D {
           field = uid
           wrap = <a href="index.php?id=|&L=0" title="Deutsche Version">D</a> | 
         }
    	
    	subparts.content_r_statisch = COA
    	subparts {           
        	content_r_statisch.10 = CONTENT
        	content_r_statisch.10 {
            	table = tt_content
            	#colPos = 2 IST DIE SPALTE RECHTS, 0 WÄRE DIE SPALTE NORMAL
            	select.where = colPos = 2
            	select.orderBy = sorting
            	select.pidInList = 38
            	}  
         }

Aber oha - wenn ich nun auf Französisch umschalte, wird der statische Text auch in Deutsch gezeigt. Ist ja logisch, den der Zeiger "select.pidInList = 38" verweist auf die Seite 38.
Lösungsansatz: Ich erstelle eine Weiche (Switch) - ->immer wenn die Sprache auf L=1 (bei mir Französisch) steht, dann zeigen den Inhalt der Seite 39 (nähmlich der Text in franz. Sprache). Das TS würde dann so aussehen:

subparts {           
        	content_r_statisch.10 = CONTENT
        	content_r_statisch.10 {
            	table = tt_content
            	#colPos = 2 IST DIE SPALTE RECHTS, 0 WÄRE DIE SPALTE NORMAL
            	select.where = colPos = 2
            	select.orderBy = sorting
            	[globalVar = GP:L = 1]
            	select.pidInList = 39
            	[else]
            	select.pidInList = 38
            	[global]
            	}  
         }

Leider funktioniert das nicht - kann da jemand netterweise helfen? Bin ich mit der Lösung auf dem Holzpfad oder schon auf dem Scheiterhaufen? 😉

hombo13 ·

Hallöle, danke dir - habe ich doch die "Gebote" des TypoScript krass missachtet. Für alle Anfänger - Meister Weiland schreibt hier ein kleine Erklärung: http://jweiland.net/typo3cms/howto/typoscript-bedingung/ Das obige Codebeispiel habe ich jetzt korrekt "ausgeschweift" (d.h. geschweifte Klammern entfernt) und die Conditions eingefügt. Alles funktioniert. Das ist doch toll, wenn man mit den "bordeigenen" Typo3-Mitteln so etwas machen kann und keine Extension braucht.🙂

############HIER KOMT DAS MENÜ MIT DEM Menu 1 cObject##################

temp.menu_1 = HMENU
# First level menu-object, textual 
wrap = <div id="navigation"> | </div>
temp.menu_1.entryLevel = 1 
temp.menu_1.1 = TMENU
temp.menu_1.1 {
	# Normal state properties
	wrap = <ul id="menu_1">|</ul>
  	noBlur = 1
  	NO.stdWrap.htmlSpecialChars = 1
  	NO.wrapItemAndSub = <li class="menu1-level1-no">|</li>
  	NO.ATagTitle.field = subtitle // title
	# Enable active state and set properties:
  	ACT = 1
  	ACT.stdWrap.htmlSpecialChars = 1
  	ACT.wrapItemAndSub = <li class="menu1-level1-act">|</li>
  	ACT.ATagTitle.field = subtitle // title
	}

# Second level menu-object, textual
temp.menu_1.2 = TMENU
temp.menu_1.2 {
	# Normal state properties
  	wrap = <ul id="levelmenu2">|</ul>
  	noBlur = 1
  	NO.wrapItemAndSub = <li class="menu2-level2-no">|</li>
	NO.ATagTitle.field = subtitle // title
	# Enable active state and set properties:

  	ACT = 1
  	ACT.stdWrap.htmlSpecialChars = 1
  	ACT.wrapItemAndSub = <li class="menu2-level2-act">|</li>
  	ACT.ATagTitle.field = subtitle // title
	}
	
# Third level menu-object, textual
temp.menu_1.3 = TMENU
temp.menu_1.3 {
	# Normal state properties
  	wrap = <ul id="levelmenu3">|</ul>
  	noBlur = 1
  	NO.wrapItemAndSub = <li class="menu3-level3-no">|</li>
	NO.ATagTitle.field = subtitle // title
	# Enable active state and set properties:

  	ACT = 1
  	ACT.stdWrap.htmlSpecialChars = 1
  	ACT.wrapItemAndSub = <li class="menu3-level3-act">|</li>
  	ACT.ATagTitle.field = subtitle // title
	}
	
############ENDE MENÜ #################################################	
	
#Submenu oben
temp.subnavigation = HMENU
temp.subnavigation.entryLevel = 1
temp.subnavigation {
	special = directory
        special.value =17
        1 = TMENU
        1 {
        	NO.allWrap = &nbsp;|&nbsp;&#124;  
            	NO.ATagTitle.field = subtitle//title                 	  
           	}
        }
####### HIER REALISIEREN WIR EINEN KLICKPFAD #########
temp.wo = HMENU
temp.wo {
	wrap = Sie befinden sich hier:&nbsp;Home&nbsp/|
	special = rootline
	special.range = 2|-1
	1 = TMENU
	1.NO = 1
	1.NO.linkWrap = |&nbsp;/&nbsp;
	}


############# Main TEMPLATE cObject for the BODY ############# 
###WIR MACHEN EINE ABFRAGE - WENN L=1 DANN BRINGE FOLGENDEN CODESCHNIPSEL, WENN NICHT BRINGE DEN CODESCHNIPSEL UNTEN#######

temp.mainTemplate = TEMPLATE
temp.mainTemplate {
	# Feeding the content from the Auto-parser to the TEMPLATE cObject:
    	template =< plugin.tx_automaketemplate_pi1
    	# Select only the content between the <body>-tags
    	workOnSubpart = DOCUMENT_BODY
    	subparts.menu_1 < temp.menu_1
        subparts.content < styles.content.get
    	subparts.col_rechts < styles.content.getRight
    	subparts.subnavigation < temp.subnavigation
    	subparts.wo < temp.wo
      	#HIER KÖNNEN WIR WEITERE SUBPARTS ANFÜGEN
      	#SPRACHWECHSLER
      	subparts.sprache_F = TEXT
	subparts.sprache_F {
           	field = uid
           	wrap = &#124;&nbsp;<a href="index.php?id=|&L=1" title="Version Français">F / </a> 
           	}
	subparts.sprache_D = TEXT
	subparts.sprache_D {
		field = uid
           	wrap = <a href="index.php?id=|&L=0" title="Deutsche Version">D</a>&nbsp;&#124; 
         	}
	#weitere Subparts hier - KOMMENTARZEICHEN ENTFERNEN
    	#subparts.irgendeinname = COA
    	#subparts {           
            	#irgendeinname.10 = CONTENT
            	#irgendeinname.10 {
            		#table = tt_content
            		#select.where = colPos = 0
            		#select.orderBy = sorting
            		#select.pidInList = {$statischer_text}
            		#}  
		#}
		
	#DAS HABE ICH ZUGUNSTEN EINES KLICKPFADES DEAKTIVIERT
	#marks.TITLE = TEXT
	#SIEHE CONSTANTS
	#marks.TITLE.field = {$meinTitel}
	
	} 


temp.mainTemplate.subparts.content_r_statisch = COA
temp.mainTemplate.subparts.content_r_statisch.10 = CONTENT
temp.mainTemplate.subparts.content_r_statisch.10.table = tt_content
#colPos = 2 IST DIE SPALTE RECHTS, 0 WÄRE DIE SPALTE NORMAL
temp.mainTemplate.subparts.content_r_statisch.10.select.where = colPos = 2
temp.mainTemplate.subparts.content_r_statisch.10.select.orderBy = sorting

#WIR MACHEN EINE ABFRAGE - WENN L=1 DANN BRINGE FOLGENDEN CODESCHNIPSEL, WENN NICHT BRINGE DEN CODESCHNIPSEL UNTEN
#ECKIGE KLAMMERN (CONDITIONS) DÜRFEN NIE IN GESCHWEIFTEN KLAMMERN STEHEN!
[globalVar = GP:L = 1]
temp.mainTemplate.subparts.content_r_statisch.10.select.pidInList = 39 
[else]
temp.mainTemplate.subparts.content_r_statisch.10.select.pidInList = 38
[global] 




############# ENDE - Main TEMPLATE cObject for the BODY #############