Benutzer-Werkzeuge

Webseiten-Werkzeuge


en:webedition:beginners-guide:listviews

Listing Documents (we:listview)

The following example displays 10 page-headings, teasers and images (if used), ordered by publication date descending. If there are more than 10 results, a link is shown to go to the next 10 results:

Listview

<ul>
    <we:listview type="document" order="we_published" desc="true" rows="10">
        <we:repeat>
            <li>
                <b><we:field name="headline" alt="we_title" hyperlink="true"/></b><br>
                <we:ifFieldNotEmpty name="image" type="img">
                    <we:field type="img" name="image" /><br>
                </we:ifFieldNotEmpty>
                <we:field type="text" name="teaser" hyperlink="true" alt="description" max="255" striphtml="true" />
            </li>
        </we:repeat>
        <we:ifBack>
            <we:back>Back</we:back>
        </we:ifBack>
        <we:ifNext>
            <we:next>Next</we:next>
        </we:ifNext>
    </we:listview>
</ul>

Look at the field-tag and it's name attribute:

<we:field name="headline" alt="we_title" hyperlink="true"/>

The template only reads headlines of documents that contain the tag:

<we:input name="headline" .../>

So be consistent with naming your document contents, if you want to list documents with more than one template! Get used to a system like:

  • headline
  • teaser
  • text

or similar, and stick to it! Other template fields that are unique to their templates don't have to be consistent, but as they are case-sensitive, develop a code guideline – and stick to it!

Do:

<!-- all small caps, spaces are underscores for legibility and compatibility -->
<we:input name="city_or_country" type="text"/>
<!-- as above, with CamelCase -->
<we:input name="CityOrCountry" type="text"/>

Don't:

<!-- You won't remember the exact name and maybe try CityOrCountry? -->
<we:input name="Cityorcountry" type="text"/>
<!-- Don't use spaces or other special characters, because the fieldnames are used as php variable names -->
<we:input name="city or country" type="text"/>

(TODO: This will probably have to go into a new page)

en/webedition/beginners-guide/listviews.txt · Zuletzt geändert: 2019/02/09 22:26 von Sascha Nemecek

Recent changes RSS feed