[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:
http://ez.no/doc/ez_publish/technical_manual/4_0/templates/the_template_language
(ezpublish uses a nodes based system for their cms, thus some the of
their templating implementation seems interesting)
http://www.smarty.net/manual/en/
(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 )
http://developer.yahoo.com/ypatterns/atoz.php
(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="...">
<f3:then>...</f3:then>
<f3:else>...</f3:else>
</f3:if>
// index  = index of result set array
// length = length of result set array
<f3:if condition="index < 2">
<f3:then>
index is less than 2
</f3:then>
</f3:if>

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

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

  <f3:else>
    <em>No related nodes.</em>
  </f3:else>

</f3:if>


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

  <f3:else>
    <em>No categories.</em>
  </f3:else>

</f3:if>

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


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
success</f3:if>

<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
success</f3:if>

<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:
=============
http://www.smarty.net/manual/en/language.modifier.date.format.php
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/formatting_and_internationalization/datetime

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

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

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>
</f3:if>


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>

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


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

Typoscript Components:
=========================
<f3:typoscript name="myt3script">
lib.menu = HMENU
lib.menu.1 = TMENU
lib.menu.1.NO{
  doNotLinkIt=1
  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