News System

As of version 0.10, a new 'News' facility was introduced, to 'automatically' handle news pages within the website.

The news facility allows website designers to create a news page template, and include that within the website. Special data entry screens allow users to enter start and end dates that the news information should appear, a synopsis, and the full news text. XDBCMS automatically includes the appropriate news pages and generates pages and links for each news item.

A worked example:

The news information for this website has been created in the following manner:

Step 1: Create a news page list

A news page list provides a list of all news items, each entry is a link to the actual news page. Create a blank template page, which is the same definition as a standard web page - i.e. contains, items such as [MENU]] and [PAGETEXT]]. Instead of using [PAGETEXT]] use the new template keyword [NEWS]], call the new template 'news_list'.

Now create a page within your website called 'news.html', which uses the 'news_list' template.

Note that you can leave the page text of the news.html page blank - it is completely over-ridden by the [NEWS]] template entry.

Step 2: Create a news text page

A news text page contains the actual news text, one news item for each page. Create a blank template page, called 'news_text', again with the same definition as a standard web page, but in this case, use [NEWS:TEXT]] instead of [PAGETEXT]].

Create a blank page, called news_text.html, and uses the 'news_text' template. Again, any text on the page is ignored - it is completely replaced by the news:text.

Note: you must set the 'page parent' of the news text page to be a 'news page list' page. Also, a news page can not have any 'child' pages, and no other pages should have the same page parent as the news text page.

Step 3: Make entries into the News items list.

At the bottom of the website definition 'tree' (after 'Blocks' and 'Stylesheet items'), there is an entry called 'News items'. Click on this entry to bring up a list of defined news entries.

Click on 'Add' to create a new news entry and enter the start and end dates that the news item should appear, the synopsis - which is used in the 'news list', and the full text, which uses the WYSIWYG editor, and should be used in the same way as when creating normal page text.

Step 4: Generate your pages

Generate your website as per normal, and you should see the news list page within the menu. When the news list page is selected, any news items that are 'current' are displayed as clickable entries, also, the news pages (synopses) should appear within the menu as child pages of the news list page.

Note: when you generate your web pages, the current date is compared with the start and end dates of the news entries to decide which are visible. In this way, you can 'pre-enter' news items, and more importantly, old news items will disappear. This takes place when the pages are (re)generated - i.e. to add or remove news items you must re-generate your website and re-publish it - there is no logic within the published website to make news items visible or invisible.

Note 2: when news items are generated, the page which contains the news text is duplicated once for each news item. Each page has a number appended to it which makes the generated file unique - these files are not automatically removed if the news item is no longer 'current' - they are simply not displayed within the news list.

Note 3: a website can contain the [NEWS]] directive in multiple places (for example within this website, it is contained within the template for the initial page, and for the main 'news' page. However, the website can contain only one [NEWS:TEXT]] directive.

Note 4: if no news items 'are current' then no news pages are created, and the news list page simply contains 'No news available'

 

Last Updated: November 9, 2006, 9:30 pm

Built using XDBCMS