2008 76-100

2008-97 hide some specific content elements

by Martin Holtz, 2008-12-19 10:25:57, old #100, typoscript

Keywords:
CONTENT, TypoScript, condition, content, renderObj, if
Description:

if you want to enable or disable some content elements f.e. within an condition, you can use the if-statement for that.

It should be esay to adapt that for your needs. Read TSref for that.

Links:
http://documentation.typo3.org/documentation/tsref/functions/if/
Code:
[globalVar = GP:test = 1]
# Shows only content elements, which have not
# uid 23,24,25
page.10 < styles.content.get
page.10.renderObj.stdWrap.if {
  isInList.field = uid
  value = 23,24,25
  negate = 1
}
[end]

2008-96 Change: "Page is being generated." Message

by Martin Holtz, 2008-12-10 12:40:47, old #99, typoscript

Keywords:
30, page_is_being_generated, CONFIG, message
Description:
It is possible via TypoScript.
Code:
config.message_page_is_being_generated (
           Page is being generated.
           If you don't see the page in 30 seconds, please reload
)

2008-95 Header redirect Location: http://typo3.org

by Erwin, 2008-12-05 09:01:27, old #97, typoscript

Keywords:
additionalHeaders, Location, redirect, TypoScript
Description:

You can do header redirects via TypoScript.

Thanks to gerards who told me:)

Code:
config >
config.additionalHeaders = Location: http://www.martinholtz.de
page >
page = PAGE
page.10 = TEXT

2008-94 Read values of MM-Tables via TypoScript f.e. DAM

by Dennis Grote, 2008-12-03 11:01:41, old #96, typoscript

Keywords:
CONTENT, renderObj, SQL, mm, mm-relation, DAM, TypoScript
Description:
This snippets helps you to read via TypoScript the Categorys of an DAM-Record.
Code:
category = CONTENT
category {
   table =  tx_dam_cat
   select {
      # the pid where the records are stored
      pidInList = 38
      selectFields = *
      join = tx_dam_mm_cat
      where = tx_dam_cat.uid = tx_dam_mm_cat.uid_foreign
      # field:uid should contain the uid of
      # the dam-record
      andWhere = tx_dam_mm_cat.uid_local = {field:uid}
      andWhere.insertData = 1
      languageField = sys_language_uid
   }
   renderObj = TEXT
   renderObj.field = title
   renderObj.wrap = |<br />
}

2008-92 Add a new pageicon under different conditions

by Stefano Cecere, 2008-11-21 14:19:47, old #94, php

Keywords:
icon
Description:
I needed to show different pageicons for pages with layout = 99. I solved it looking into the code of kb_page_icon and found a solution.
Code:
/*
First create a new extension, in this extension you hook into tcemain to check when pages get layout=99 set. When that happens you assign "ICON:cat" to the field "Module". When any other layout is set, you empty the field "Module".

Then you define which image "ICON:cat" should point to, in ext_tables.php

Of course you need to create some icons for this to work.
*/

// FILE: class.user_pageicon_t3libtcemain.php:
class user_pageicon_t3libtcemain {

function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj) {
if ($table=='pages') {
if ($fieldArray['layout'] == 99) {
$fieldArray['module'] = 'ICON:cat';
} elseif (isset($fieldArray['layout'])) {
$fieldArray['module'] = '';
}
}
}

}

//FILE: ext_tables.php
if (!defined ('TYPO3_MODE')) die ('Access denied.');

$data = array('ICON:cat' => array('icon' => '../'.t3lib_extMgm::siteRelPath('user_pageicon').'category_icons/pages.gif'));
$ICON_TYPES = t3lib_div::array_merge_recursive_overrule($ICON_TYPES, $data);

//FILE: ext_localconf.php
if (!defined ('TYPO3_MODE')) die ('Access denied.');

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:user_pageicon/class.user_pageicon_t3libtcemain.php:&user_pageicon_t3libtcemain';

2008-90 Some menuitems with special classes

by Martin Holtz, 2008-11-03 21:08:08, old #92, typoscript

Keywords:
HMENU, MENU, CASE, override, stdWrap, typoscript, LOAD_REGISTER, condition
Description:

This is an example which describes, how to define an special class for some pages.

I show two different methods, take that which is more usefull for you. The first method gives you the possibility to define some special classes for some pages, the second method only works, if you have only one different class.

And for better debugging i put the class into the title.

The main idea is, to put the class into an register, which can than inserted into the class or tilte-tag.

While wrapItemAndSub has no stdWrap property, you have to do that insertData on allWrap.

Code:
lib.navigation = HMENU
lib.navigation {
  1 = TMENU
  1 {
    noBlur = 1
    NO.allWrap = <li title="{register:class1} {register:class2}">|</li>
    NO.allWrap {
       prepend = LOAD_REGISTER
       prepend {
                # first method
          class1.cObject = CASE
          class1.cObject {
             key.field = uid
             default = TEXT
             default.value = defaultclass
             458 = TEXT
             458.value = classforpage458
                        459 = TEXT
                        459.value = classforpage459
      }
                # second method
                class2 = defaultclass
                class2.override = classforpage458and459
                class2.override.if.isInList.field = uid
                class2.override.if.value = 458,459
   }
       insertData = 1
    }
    NO.stdWrap.htmlSpecialChars = 1
    ACT = 1
    ACT.allWrap < .NO.allWrap
    ACT.allWrap = <li title="{register:class1} {register:class2}">|
    ACT.wrapItemAndSub = |</li>
    wrap = <ul>|</ul>
  }
  2 < .1
  3 < .1
  4 < .1
  5 < .1
 }

2008-89 Extra classes for linkitems if special pages are inside

by Georg Ringer, 2008-10-19 14:25:39, old #91, typoscript

Keywords:
TMENU, css, if
Description:
Use this snippet to set extra classes to the link items by knowing the id or modify the if and use another field to compare
Code:
NO {
   ATagParams.stdWrap.cObject = COA
   ATagParams.stdWrap.cObject {
      10 = COA
      10 {
         10 = TEXT
         10.value = class="important"

         if {
            value = 11
            isInList.field = uid
         }
      }
      20 <.10
      20 {
         10.value = class="important2"
         if.value = 9,8
      }

   }
}

2008-88 Image width based on colPos

by Ben van 't Ende, 2008-10-16 15:46:16, old #90, typoscript

Keywords:
colPos, IMAGE, image
Description:
This snippet provides different imagewidths for the different columns for the IMAGE element.
Code:
temp.tt_content.image < tt_content.image

tt_content.image = CASE

tt_content.image {

  key.field=colPos





  1 < temp.tt_content.image

  2 < temp.tt_content.image

  3 < temp.tt_content.image

  default < temp.tt_content.image





  1.20.maxW= 145 #col-02

  2.20.maxW= 190 #col-04

  3.20.maxW= 100

  default.20.maxW= 345

}

temp.tt_content.image >

2008-87 News title as page title

by Thomas Loeffler, 2008-10-13 14:44:01, old #89, php

Keywords:
tt_news, title, page, FE
Description:
In the detail view of tt_news, you can overwrite the page title to the title of the news record. Multilanguage support.
Code:
[globalVar = TSFE:id = {$newsSinglePid}]
temp.newsTitle = RECORDS
temp.newsTitle {
source = {GPvar:tx_ttnews|tt_news}
source.insertData = 1
tables = tt_news
conf.tt_news >
conf.tt_news = TEXT
conf.tt_news.field=title
wrap = <title>|</title>
}
page.config.noPageTitle = 2
page.headerData.10 >
page.headerData.10 < temp.newsTitle
[global]

2008-86 News title as page title

by Thomas, 2008-10-13 14:42:42, old #88, typoscript

Keywords:
tt_news, title, page, FE
Description:
In the detail view of tt_news, you can overwrite the page title to the title of the news record. Multilanguage support.
Code:
[globalVar = TSFE:id = {$newsSinglePid}]
temp.newsTitle = RECORDS
temp.newsTitle {
source = {GPvar:tx_ttnews|tt_news}
source.insertData = 1
tables = tt_news
conf.tt_news >
conf.tt_news = TEXT
conf.tt_news.field=title
wrap = <title>|</title>
}
page.config.noPageTitle = 2
page.headerData.10 >
page.headerData.10 < temp.newsTitle
[global]

2008-85 Page index + Content elements index + counter

by nubla, 2008-10-10 16:17:24, old #87, typoscript

Keywords:
typoscript, menu, coa, content
Description:
This snippet will generate a list of pages with a counter next to it indicating how many active content elements there are on that page. It then lists the headers of those content elements. Useful if you don't want to create a whole tree of pages to do this and want to work with content elements.
Code:
// Page 1: 24010
// Page 2: 24012
// Page 3: 24013
// Page 4: 24015
temp.PageListIndex = COA
temp.PageListIndex {
   // Function for 'Page1'
   10 = COA
   10 {
      // Get the title
      10 = CONTENT
      10 {
         table = pages
         select.uidInList = 24010
         renderObj = TEXT
         renderObj.field = title
         renderObj.wrap = <h6>|
         renderObj.typolink.parameter.field=uid
      }
      // Count how many active content elements with colPos=0
      20 = TEXT
      20 {
         numRows {
            table = tt_content
            select {
               pidInList = 24010
               where = colPos=0 AND hidden=0 AND deleted=0
            }
         }
         noTrimWrap=| (active |)</h6>|
      }
      // List active 'headers'
      30 = CONTENT
      30 {
         table = tt_content
         select {
            pidInList = 24010
            orderBy = sorting
            where = colPos=0 AND hidden=0 AND deleted=0
         }
         renderObj = TEXT
         renderObj {
            field = header
            wrap=<li>|</li>
            typolink.parameter.field=pid
            typolink.parameter.dataWrap=|#{field:uid}
            if.isTrue.field=header
         }
         wrap = <ul>|</ul>
      }
   }

   // Copy the function for 'Page 2'
   20 < .10
   20.10.select.uidInList = 24012
   20.20.numRows.select.pidInList = 24012
   20.30.select.pidInList = 24012

   // Copy the function for 'Page 3'
   30 < .10
   30.10.select.uidInList = 24013
   30.20.numRows.select.pidInList = 24013
   30.30.select.pidInList = 24013

   // Copy the function for 'Page 4'
   40 < .10
   40.10.select.uidInList = 24015
   40.20.numRows.select.pidInList = 24015
   40.30.select.pidInList = 24015
}

2008-83 Finding the UID of the General Record Storage page using TypoScript

by Peter Klein, 2008-09-24 17:45:05, old #85, typoscript

Keywords:
fullRootLine, storage_pid
Description:

Returns the UID of the "General Record Storage page"

NOTE: If your site has MORE than 9 levels, you 'll have to change the "fullRootLine:9,storage_pid,slide" to reflect that.

Code:
page.10 = TEXT
page.10.data = fullRootLine:9,storage_pid,slide
page.10.wrap = UID of <b>General Record Storage page:</b>&nbsp;|<br>

2008-82 Date countdown

by Peter Klein, 2008-09-24 17:43:03, old #84, typoscript

Keywords:
COA_INT, date, cObject, prioriCalc, strftime
Description:
Create a countdown that displays the days until a specified date. This typoscript snippet simply outputs "It is now xx days until xxx" where xx is the days until the xxx date.
Code:
# Put following in the constants field:
# The countdown date (In UNIX time format)
lib.countdown.date = 1142095231

# And put the following into the SETUP field:
lib.countdown = COA_INT
lib.countdown {
  10 = TEXT
  10.cObject = TEXT
  10.cObject.data = date:U
  10.cObject.wrap = ({$lib.countdown.date} -|)/86400
  10.prioriCalc = intval
  10.wrap = It is now&nbsp;|&nbsp;days until&nbsp;
  20 = TEXT
  20.value = {$lib.countdown.date}
  20.strftime = %d %B %y
}

2008-79 Rootline Menu in <title>-Tag

by Stefan Lang, 2008-09-22 10:43:15, old #81, typoscript

Keywords:
special.rootline, COA, HMENU, headerData, title
Description:
This Snippet shows how to get a complete rootline-menu in your website head into the title-Tag
Code:
page {
        headerData {
                5 = COA
                5 {
                        wrap = <title>|</title>
                        10 = TEXT
                        10 {
                                stdWrap.noTrimWrap = || - |
                                value = Websitetitle
                        }
                        20 = HMENU
                        20 {
                                special = rootline
                                special.range = 1|-1
                                1 = TMENU
                                1 {
                                        NO {
                                                stdWrap.field = subtitle // title
                                                linkWrap = | - ||*|| - ||*||
                                                doNotLinkIt = 1
                                        }
                                }
                        }
                }
        }
}

2008-77 Using Transparent PNG's in IE5/6 without JS

by Peter Klein, 2008-09-17 20:19:32, old #79, typoscript

Keywords:
IMG_RESOURCE, IMAGE, png
Description:

Sometimes you need to make a site compatible with the old crappy IE5/6 when using transparent PNGs.

People often resort to various Javascripts to convert the IMG tags into filters for IE.

But the same can be done directly by Typoscript! Below is an example.

Code:
# This is the normal IMG tag shown in good browsers
lib.pngImage = COA
lib.pngImage {
  10 = IMAGE
  10.file = fileadmin/img/car.png
  10.file.import = uploads/tx_templavoila/
  10.file.import.field = field_image
  10.file.import.listNum = 0
  10.file.maxW = 600
}

# If the browser is IE, and the version lower than 7,
# then we modify the lib.pngImage object
[browser = msie] && [version=  <7]
lib.pngImage = COA
lib.pngImage {

  # first we create a dummy register value, in order to fill
  # the TSFE:lastImgResourceInfo array.
  20 = LOAD_REGISTER
  # The dummy object is just a copy of the original IMAGE object
  20.dummy.cObject < .10
  # But we change the type from IMAGE to IMG_RESOURCE
  20.dummy.cObject = IMG_RESOURCE

  # And unset the original 10 object
  10 >

  # Then we create a SPAN tag instead of the IMG tag.
  # The span tag uses the AlphaImageLoader filter
  # to display the transparent PNG correctly in IE.
  30 = TEXT
  30.value = <span style="width:{TSFE:lastImgResourceInfo|0}px;height:{TSFE:lastImgResourceInfo|1}px;display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{TSFE:lastImgResourceInfo|3}', sizingMethod='scale');"></span>
  30.insertData = 1
}
[GLOBAL]
# Done! - Back to normal..

2008-76 noBlur for other browsers, remove dashed line around linked images

by Cyrill Helg, 2008-09-09 20:16:10, old #78, typoscript

Keywords:
image, css, menu, typoscript, GMENU
Description:

When you add the TS below, the dashed lines on a clicked link will disappear in all common browsers.

Remember that this is bad for accessibility, because you can't select the image links with the tab key any longer. (You won't find out which on is selected)

Code:
//...
1 = GMENU
1.NO = 1
1.NO {
ATagParams = style="outline: none;"
//...
}