This page is still a beta!

1.5. Examples

Quick Shop - 1 Filter

It is very simple to configure the content objects

  1. SELECTBOX

  2. CHECKBOX and

  3. RADIOBUTONS

All have a master template. You copy the master template to your view and you configure the properties only, which aren't configured for your needs.

If you are interested in the power of a master template, please look at

  1. Reference 'SELECTBOX' on page 30 below

After copying you will see the powerful TypoScript code supported by the TypoScript Object Browser in your view array. It should be comprehensible, how to change any feature and property of your filter to your needs.

See section

  1. 'TypoScript Object Browser' on page 15 above and

  2. Reference 'master_templates' on page 28 below

See the examples below.

SELECTBOX

Illustration 25: Quick Shop with the filter SELECTBOX

See the TypoScript on the next page.

TypoScript

See the line

  1. // The filter becomes the property SELECTBOX

below in the snippet

plugin.tx_browser_pi1 {

  ...

  views {

    list {

      1 {

        select = ...

        filter {

          tx_quickshop_categories {

            // The filter becomes the property SELECTBOX

            title < plugin.tx_browser_pi1.displayList.master_templates.selectbox

            title {

              // Configuration SELECTBOX begin

              first_item {

                stdWrap {

                  data >

                  value = Select a Category

                  lang {

                    de = Kategorie wählen

                  }

                }

              }

              wrap = <span class="selectbox">|</span>

              wrap {

                item {

                  stdWrap {

                    crop = 60 | ... | 1

                  }

                }

              }

              // Configuration SELECTBOX end

            }

          }

        }

      }

    }

    single {

      ...

    }

  }

}

Easy way of configuring: See section 'TypoScript Object Browser' on page 15 above.

CHECKBOX

Illustration 26: Quick Shop with the filter CHECKBOX

TypoScript

See the line

  1. // The filter becomes the property CHECKBOX

below in the snippet

plugin.tx_browser_pi1 {

  ...

  views {

    list {

      1 {

        ...

        filter {

          tx_quickshop_categories {

            // The filter becomes the property CHECKBOX

            title < plugin.tx_browser_pi1.displayList.master_templates.checkbox

          }

        }

      }

    }

  }

}

RADIOBUTTONS

Illustration 27: Quick Shop with the filter RADIOBUTONS

TypoScript

See the line

  1. // The filter becomes the property RADIOBUTONS

below in the snippet

plugin.tx_browser_pi1 {

  ...

  views {

    list {

      1 {

        ...

        filter {

          tx_quickshop_categories {

            // The filter becomes the property RADIOBUTONS

            title < plugin.tx_browser_pi1.displayList.master_templates.radiobutons

          }

        }

      }

    }

  }

}

Green Cars - Dynamic Filter

The Browser filters are dynamically by default. This means:

  1. If a filter item hasn't any hit, it won't be displayed.

  2. Each filter controls all others..

Exercise

We will change some TypoScript of the page http://gruene-autos.org/ for demonstration only.

See the examples below.

SELECTBOX (Default)

Illustration 28: Green Cars with three selectboxes - each with size = 1

This is the start page of http://gruene-autos.org/

It has three filters designed as selectboxes. Each displays one item only (HTML property size is 1).

The TypoScript for the three selectboxes should be clear (see the snippet below).

TypoScript

See the lines

  1. // This filter becomes the property SELECTBOX

below in the snippet

plugin.tx_browser_pi1 {

  ...

  views {

    list {

      1 {

        select = ...

        filter {

          tx_greencars_engine {

            // This filter becomes the property SELECTBOX

            title < plugin.tx_browser_pi1.displayList.master_templates.selectbox

            title {

              first_item {

                stdWrap {

                  data = LLL:EXT:green_cars/locallang_db.xml:tx_greencars_main.engine

                }

              }

              wrap = |

            }

          }

          tx_greencars_pricebracket {

            // This filter becomes the property SELECTBOX

            title < plugin.tx_browser_pi1.displayList.master_templates.selectbox

            title {

              first_item {

                stdWrap {

                  data = LLL:EXT:green_cars/locallang_db.xml:tx_greencars_main.pricebracket

                }

              }

              wrap = |

              order {

                field = uid

              }

            }

          }

          tx_greencars_type {

            // This filter becomes the property SELECTBOX

            title < plugin.tx_browser_pi1.displayList.master_templates.selectbox

            title {

              first_item {

                stdWrap {

                  data = LLL:EXT:green_cars/locallang_db.xml:tx_greencars_main.type

                }

              }

              wrap = |

            }

          }

        }

      }

    }

  }

}

SELECTBOXES size = 5

For a better understanding of dynamic filters we change the properties of each selectbox. We like to display five items per box and we remove the title (the first item). See the illustration below.

Illustration 29: Green Cars with three selectboxes - each with size = 1

TypoScript

// Set the size of all boxes to 5

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_engine.title.size = 5

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_pricebracket.title.size = 5

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_type.title.size = 5

// Don't display the first_iem

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_engine.title.first_item = 0

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_pricebracket.title.first_item = 0

plugin.tx_browser_pi1.views.list.1.filter.tx_greencars_type.title.first_item = 0

Selection Case

We are interested in cars

  1. with a diesel or domestic gas engine

  2. with a price-bracket from 20.000 EUR to 25.000 EUR

Illustration 30: Green Cars with three selectboxes - each with size = 1

The values in the boxes will be changed after sending the form:

  1. every item has a new number of hits

  2. there are some items without any hit and they won't be displayed like

    1. Coupe

    2. all engines without a selection (of course)

    3. all price-brackets without a selection (of course)

Illustration 31: Green Cars with three selectboxes - each with size = 1

Change the Behavior

Display price-brackets even if they haven't any hit

Illustration 32: Green Cars with three selectboxes - each with size = 1

TypoScript

// Display price-brackets even if they haven't any hit

plugin.tx_browser_pi1 {

  views.list.1.filter.tx_greencars_pricebracket.title.wrap.item.display_without_any_hit = 1

}

Display price-brackets without the number of  hits

Illustration 33: Green Cars with three selectboxes - each with size = 1

TypoScript

// Display price-brackets without the number of  hits

plugin.tx_browser_pi1 {

  views.list.1.filter.tx_greencars_pricebracket.title.wrap.item.display_hits = 0

}

Organiser1

Organiser (extKey: org) is a powerfull database for organisations, companies and organisers: You can publish all data in real terms. You can design an organisation with headquarters, locations, staff, events, news and documents. Org displays data in list, single and calendar views. Org hasn't any PHP code. It is based on the TYPO3-Fronend-Engine Browser. You can control and develop org by plugins and TypoScript. Org is in development. We intend to publish org at the 1st of April, 2011.

- Filter for a period (data area)

1

Organiser (extKey: org) is a powerfull database for organisations, companies and organisers: You can publish all data in real terms. You can design an organisation with headquarters, locations, staff, events, news and documents. Org displays data in list, single and calendar views. Org hasn't any PHP code. It is based on the TYPO3-Fronend-Engine Browser. You can control and develop org by plugins and TypoScript. Org is in development. We intend to publish org at the 1st of April, 2011.

This is a typical example for a calendar.

This is the case:

  1. dates of events are stored in a field "datetime"

  2. the format of a date is a timestamp

  3. the table tx_org_cal contains the field datetime. The table.field-syntax is: tx_org_cal.datetime

Preconditions

We have configured a list view (and a single view of course) for the table tx_org_cal.

HTML Template

We have added the marker ###TX_ORG_CAL.DATETIME### to our HTML template into the filter section.

See section HTML Template on page 13 above.

TypoScript Snippet SELECTBOX

  1. plugin.tx_browser_pi1 {

  2.   views {

  3.     list {

  4.       201 {

  5.         name    = Calendar

  6.         select (

  7.           tx_org_cal.title,

  8.           tx_org_cal.datetime

  9.         )

  10.         csvLinkToSingleView = tx_org_cal.title

  11.         filter {

  12.           tx_org_cal {

  13.             datetime < plugin.tx_browser_pi1.displayList.master_templates.selectbox

  14.           }

  15.         }

  16.       }

  17.     }

  18.     ...

  19.   }

  20. }

Result in the Frontend

Illustration 34: Calendar with select box

Comment

Line 11 to 13 (see page above): we allocates a filter for tx_org_cal.datetime in form of a SELECTBOX.

The items of the SELECTBOX are in our case:

<option value="1283968800">1283968800 (2)</option>

<option value="1304892000">1304892000 (1)</option>

<option value="1315591200">1315591200 (3)</option>

This means:

  1. We have two dates at 1283968800, one date at ... and three dates at ...

But we don't want for every date an item in the selectbox. We want something like "Display the events of the last year, this year and the next year".

We want something like this:

<option value="10">2009 (0)</option>

<option value="20">2010 (2)</option>

<option value="30">2011 (4)</option>

We add an area out of the master template section and configure some properties.

TypoScript Snippet with Area

  1. plugin.tx_browser_pi1 {

  2.   views {

  3.     list {

  4.       201 {

  5.         name    = Calendar

  6.         select (

  7.           tx_org_cal.title,

  8.           tx_org_cal.datetime

  9.         )

  10.         csvLinkToSingleView = tx_org_cal.title

  11.         filter {

  12.           tx_org_cal {

  13.             datetime < plugin.tx_browser_pi1.displayList.master_templates.selectbox

  14.             datetime {

  15.               // Every item should be displayed even though it hasn't any hit

  16.               wrap.item.display_without_any_hit = 1

  17.               // Order the items by uid (and not by value)

  18.               order.field = uid

  19.               // Allocates the master template sample_period

  20.               area < plugin.tx_browser_pi1.displayList.master_templates.areas.sample_period

  21.             }

  22.           }

  23.         }

  24.       }

  25.     }

  26.     ...

  27.   }

  28. }

Comment

Line 16:Every item should be displayed even though it hasn't any hit

Line 18:Order the items by uid (and not by value)

Line 20:This is the most important line. We allocate the master template sample_period.This template provides by default: - a period of years - a period from last year to next year (be aware of the relative period!) - and the items are formatted as year only.

Every property is configurable.

We get, what we want:

<option value="10">2009 (0)</option>

<option value="20">2010 (2)</option>

<option value="30">2011 (4)</option>

Properties and Possibilities

Please refer to the Reference AREAS on page 32 below.