[TYPO3-50-general] Beer3 - Array Syntax and View Helpers

Kevin James cms.templating at gmail.com
Wed Oct 29 12:30:58 CET 2008

Hi Sebastian

Firstly I must say, that I'm really impressed with the work you have
been doing thus far. I think it's awesome. Secondly I'm an entry level
php programmer, but I have worked with a lot of cms systems and
varying templating languages. When you need a tester I'll be more than
happy to assist. Below I have compiled a list of ideas that I think
would work really well in beer3 and typo3 in general.

Please let me know if you need any clarification on the below syntax.

Syntax Suggestions:

Links of interest:
(ezpublish uses a nodes based system for their cms, thus some the of
their templating implementation seems interesting)
(where possible we should stick to a similar naming convention, thus
making the adaptation to the f3 templating syntax much easier for
other developers/ designers )
(more popular yui patterns to serve as beer3 widgets, maybe they can
also be built with typoscript as a library)

Based on the namespace "F3":
<f3:if condition="...">
// index  = index of result set array
// length = length of result set array
<f3:if condition="index < 2">
index is less than 2

<f3:if condition="index < length">
Display last item node

F3 dealing with related nodes:
<f3:if condition="relatednodes.length > 0">
    <f3:then id="relatednodes" maxlength="5">
      <a href="{url}">
      // note a f3:then with a f3:then command
      <f3:then condition="index < length">

    <em>No related nodes.</em>


F3 Global Categories System:
<f3:if condition="itemcategories.length > 0">
    <f3:then id="itemcategories">
      <a href="categoryUuid={uid}">
      <f3:if condition="index < length"><br></f3:if>

    <em>No categories.</em>


<f3:cat name="fruits" class="categories" parent="/fruit" />
Select a fruit: <select name="fruit">
<f3:then id="fruits">
<option value="{name}">{label}</option>

String Manipulation and String Comparisons:
<f3:if condition="isNull('')">isNull success</f3:if>

<f3:if condition="!isNull('sometext')">!isNull success</f3:if>

<f3:if condition="replace('javascript','java','typo')=='typoscript'">replace

<f3:if condition="trim('  typo3  ') == 'typo3'">trim success</f3:if>

<f3:if condition="truncate('Alpahnumern',5)=='Al...'">tuncate success</f3:if>

<f3:if condition="concat('Flo','w3')=='Flow3'">concat success</f3:if>

<f3:if condition="substring('someitem', 3, 4)=='e'">substring success</f3:if>

<f3:if condition="getDefault('','default')=='default'">getDefault

<f3:if condition="regexp('chars','chars')==true">matches success</f3:if>

<f3:if condition="escapeQuotes('\'')=='\\\''">escapeQuotes success</f3:if>

<f3:if condition="random(10)=='3'>Its a one-in-ten occurrence!</f3:if>

Testing Dates:

<f3:if condition="firstpubDate >= weeks(0)">
item published this week!

<f3:if condition="firstpubDate >= days(-1) && firstpubDate <= days(0)">
Item published yesterday!

Defining Local Variables:
The f3:var or f3:def command can be used to create local variables.
Example of setting a local variable called "teaser" to the first 400
characters of the body:
<f3:var id="teaser" value="substring(body,0,400)" />

Random display of elements:
<f3:var id="rand" value="random(length)" />
<f3:if condition="index == rand">
<p>Here is the random one: {title}</p>

XML/RDF Import Component:
Remote XML/RDF Component uses the F3 templating syntax.

Remote xml title: {xml.title}
Remote xml subtitle: {xml.subtitle}

Remote xml URLs:
<f3:then id="xml.link">
  Link: {href}

<f3:then id="xml.entry" maxlength="5">
  Title: {title}
  Link: {link.href}
  Author: {authorName}
  Published: {publishedDate}

Widget/Dynamic Components:
<f3:widget name="paginator" config="...">
  displays paginator

Typoscript Components:
<f3:typoscript name="myt3script">
lib.menu = HMENU
lib.menu.1 = TMENU
  before.data = field:uid
  before.wrap= <a href="javascript:ajaxpage('index.php?id=|', 'content');">
  stdWrap.field = title
  after.data = field:title
  after.wrap =|</a>&nbsp;
</f3:typoscript >

Keep up the great job.

More information about the TYPO3-project-5_0-general mailing list