The news mechanism is used to automatically generate a list of news. This is provided with a date validity range and can, for example, make predefined messages available on a time-controlled basis. On the other hand, messages can be automatically moved to the archive when the time is up.
The news is displayed in the same way as with the accordion directive.
The news directive can be embedded in any HTML page. Depending on the use, different parameters are supported. <ea-news data-news-title="All my news" data-news-mode="new" data-news-limit="2" data-news-txt-len="200" data-news-init-idx="0" </ea-news> The parameters have the following effect. The first "data-news-title" is the heading and is displayed with the h1 tag.
The second "data-news-mode" can assume the following values.
  • all - all entries for which the date 'newFrom' has been reached are displayed, regardless of the date 'newTo'.
  • new - all entries are displayed for which the date 'newFrom' has been reached and 'newTo' has not yet passed.
  • arc - all entries are displayed for which the date 'newFrom' has been reached and 'newTo' has already passed.
The "data-news-limit" parameter determines the maximum number of news to be displayed if more news meet the criteria for display than are desired at the relevant point. (This can be of interest for a home page, for example.)
The parameter "data-news-txt-len" limits the number of characters displayed in the collapsed state. If this value is 0, no preview text is displayed.
The parameter "data-news-init-idx" indicates which New is initially expanded. If the value is 0, no New initial is opened.
Note: In order to display all entries recorded in the news JSON file, the author must ensure that either the 'all' mode is used on at least one HTML page or that 'new' and 'arc' are used on two pages without restriction ('data -news-limit') is selected.
The JSON file "newsList.json" has the following structure: {"_comment": ["By default all News params are strings.", "img, body and imgBody are string arrays with the same length in one object (new).", "default is length===1)", "newTo: The last day when this new will be show in 'news' but can show in 'new/archiv'.", "--------------------------------------------------------------------------", "title: Title of new (large letters)", "newFrom: The first day when this new is shown. (little letters)", "---------------------------------------------------------------------------", "img: (0ptional) ohne picture | body: (optional) Body text", "imgBody: Labeling of picture | the following special characters can be used", "---------------------------------------------------------------------------", "href: Any HTML page can be integrated ", "---------------------------------------------------------------------------", "Hints:", "All texts are continuous texts without the possibility of inserting line breaks.", "The arrays of the 'body' and 'img' parameters must have the same number of elements. ", "If the texts in some 'body' parameters remain empty, they MUST BE DEFINED IN ", "A DIFFERENT WAY (e.g. different number of spaces)"], "entries": [ { "newFrom": "2023-03-15", "newTo": "2024-12-31", "title": "Der neue Brutkasten wird bezogen", "body": ["Wir liegen fast täglich mit dem Fotoapparat auf der Lauer. Jetzt haben wir eine relative Gewißheit, dass der Nistkasten angenommen wird. Es geht im Munutentakt rein und raus. Da wir wohl ein Nest gebaut?"], "img": [], "imgBody": [], "href": "content/html/Nistkasten-2023.html" }, { "newFrom": "2023-01-01", "newTo": "2024-12-31", "title": "Unsere nächste Reise", "body": ["Wir planen wieder eine Kurzreise. Diesmal soll es auf die Nordseeinsel Norderney gehen."], "img": [], "imgBody": [], "href": "" }, { "newFrom": "2022-07-30", "newTo": "2022-09-30", "title": "Wir wollen nach Lissabon", "body": ["Corona hatte uns einen Strich durch die Rechnung gemacht. Jetzt planen wir endlich den Trip nach Lissabon. Im Oktober 2022 war es endlich soweit."], "img": ["content/pictures/Lissabon-Praca-do-Comercio-vom-Wasser.jpg"], "imgBody": ["Ein Blick auf die Alfama, ein Teil der Altstadt von Lissabon vom Wasser aus"], "href": "" } ] } The values ​​from the JSON file are processed according to the following rule:
  • If both fields "body" and "img" are specified, the display will automatically have two columns.
  • If only one of the two fields is specified, it is displayed in one column.
  • The "imgBody" field is always displayed as a caption.
  • If none of the two fields "body" and "img" are specified, this part of the display is suppressed. Then there should be an "href" entry.
  • In the "href" field, an optional HTML page can be specified, which is attached to the part defined above. This may be necessary if, for example, a link is to be displayed. Html code cannot be displayed in the "body" field, only format-free text can be used here.