[TYPO3-ttnews] new feature: Optionsplit for tt_news

Rupert Germann rupi at gmx.li
Sun Apr 6 18:57:10 CEST 2008


Hi folx,

I just merged the tx_ttnews-2.6.0dev branch back to trunk. Means: you can
download it from http://typo3xdev.sourceforge.net/ from tomorrow on or so.
in case you need it more urgent you can also get the latest tt_news dev
version from [1].

Changes since my last post:

*OPTIONSPLIT* FOR TT_NEWS 
Yeah :-)
 
I wrote this capitalized to emphasize that this is probably the most
important new feature in tt_news since nested categories - and IMHO
optionSplit is one of the best inventions ever since sliced bread.
Despite it is mentioned right at the beginning of TSRef [2] it's not so
famous and widely used as it would deserve it. Optionsplit is part of TYPO3
since "ever" but I used only a few times until now. 
(Thanks to Jonas Dübi and cabag.ch for the initial patch which inspired me
to extend this principle to many more options)

now you'll ask yourself: for what do I need this?

Did you ever needed to configure a certain option only for one or a few of
the news showing in a list? until now you'd need one plugin for each
different option.

example: 
take a look at the page I used for the performance tests:
http://rgdata.de/fileadmin/user_upload/tt_news_profiling.pdf

the middle column shows 3 news list plugins. You can easily distinguish them
by the image sizes. You can see how they are configured in the TS which is
also in this pdf. By using optionSplit it is possible to substitute the 3
plugins by 1 and this one plugin has far more configuration possibilities
than the 3 together had before.   

consider this:
plugin.tt_news {
  displayList.image.file.maxW = 300||300|*|200|*|100||80||65
}

you see that the values are divided by 2 different tokens: '|*|' and '||' 
'|*|' divides the parameters to sections: first |*| middle |*| last
'||' divides a section to subparts. 
The behaviour of the subparts differs depending on the section: in 'first'
and 'last' the values are used in the order as they are listed, in 'middle'
the values are cycled.
How often the middle section is cycling depends on the amount of items which
are shown ( = plugin.tt_news.limit).

assumed the list limit is set to 10 the displayed news will have the
following image sizes:
1:   300px  
2:   300px 
3:   200px
4:   200px
5:   200px
6:   200px
7:   200px
8:   100px
9:   80px
10:  65px

but not only the image sizes are optionsplitted - it's possible to use
optionSplit on ALL parameters in lists!
even wraps can be splitted:

plugin.tt_news {
  displayLastest.title_stdWrap ( 
     <h1>|</h1>||<h1>|</h1>|*|
     <h2>|</h2>|*|
     <h3>|</h3>||<h3>|</h3>||<h3>|</h3>
  )
}
means: First 2 items will get h1 headers, the last 3 items will get h3. All
items in between (middle) will get h2.



so far so good - but besides articles in lists there are other things in
news where the same configuration data is used for multiple items: 
template parts and images in the single view.

OptionSplit for template parts (altLayoutsOptionSplit) allows you to
directly access certain template parts in a template. Contrary to the good
old 'alternatingLayouts' feature the current template part is not
determined by a simple counter but by an optionsplitted value. 
consider this:

plugin.tt_news {  
  altLayoutsOptionSplit = 0||1|*|2||3||4|*|5||5||5
}

assumed the list limit is set to 11 the template parts will be choosen in
the following order:
1:   part 0 (###NEWS###)
2:   part 1 (###NEWS_1###) 
3:   part 2 (###NEWS_2###)
4:   part 3 (###NEWS_3###)
5:   part 4 (###NEWS_4###)
6:   part 2 (###NEWS_2###)
7:   part 3 (###NEWS_3###)
8:   part 4 (###NEWS_4###)
9:   part 5 (###NEWS_5###)
10:  part 5 (###NEWS_5###)
11.  part 5 (###NEWS_5###)

btw: it's also possible not to use all optionsplit sections.
something like:
  altLayoutsOptionSplit = 3||5||2||1||4||1||5||5
will simply output the template parts in the listed order.
(if limit is greater than the amount of split items to last value will be
repeated)


OptionSplit for images in single view (imageMarkerOptionSplit)

with the new parameter "imageMarkerOptionSplit" it's possible to use
multiple imagemarkers for the images in the single view.
example: 
plugin.tt_news.imageMarkerOptionSplit = 1|*|2
will render the first image to marker ###NEWS_IMAGE_1### and all others to
marker ###NEWS_IMAGE_2###

the other image-related parameters are optionssplitted, too. 
consider this:

  page.10.30 =< plugin.tt_news
  page.10.30 {
    code = single2
    displaySingle {
      # configures tt_news to use 3 image markers. The first 
      # image is rendered to marker 1, the last 2 images 
      # are renderd to marker 3, the rest will go to marker 2.
      imageMarkerOptionSplit = 1|*|2|*|3||3

      image.file.maxW = 300|*|90|*|200||200
      image.file.maxH = 300

      # this configures tt_news to wrap only each "middle" (marker2) image  
      # with <div class="sv-img-small"> (div is closed later)
      image.wrap = | |*|<div class="sv-img-small">|*| | || | 

      # This wraps all images in the first image marker to  
      # <div class="sv-img-big">|</div>.
      # marker 2 and 3 will be wrapped to 
      # <div class="sv-img-small-wrapper">|</div>
      imageWrapIfAny (
        <div class="sv-img-big">|</div>|*|
        <div class="sv-img-small-wrapper">|</div>
      )
      caption_stdWrap.required = 0
      
      # This wraps the image caption in a <p> tag. have a look at 
      # the "middle" wrap which closes the div from above to surround 
      # the image and its caption
      caption_stdWrap.dataWrap ( 
        <p class="news-single-imgcaption">|</p>|*|
        <p class="news-single-imgcaption">|&nbsp;</p></div>|*|
        <p class="news-single-imgcaption">|&nbsp;</p>||
        <p class="news-single-imgcaption">|&nbsp;</p>
      )
  }

weird, isn't it? ;-)



besides this I also made a lot of changes and improvements in the "news
admin" BackEnd module and the flexform -> see changelog for details [3].



greets
rupert
  

[1]
http://rgdata.de/fileadmin/user_upload/T3X_tt_news-2_6_0-z-200804061826.t3x

[2]
http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/3/1/#id3750526

[3]
http://typo3xdev.svn.sourceforge.net/viewvc/*checkout*/typo3xdev/tx_ttnews/trunk/ChangeLog



More information about the TYPO3-project-tt-news mailing list