Create a news entry list

Posted by Helmuti_pdorf on 20 Feb 2011 09:13, last edited by Helmuti_pdorf on 20 Feb 2011 09:15

Tags: news notice

rating: 0+x

Original Question cames from http://community.wikidot.com/forum/t-303831/news-entry-to-my-website#post-1006569

Here I copied the answer from RobElliottRobElliott

To display the notices on the noticeboard page you need to add a ListPages module. The full steps I used to display the notices on the page here are shown below. I always use a dataform for notices.

1. new page button

1) on an admin page where you want to place a button to add a new notice add the following new page button code:

[[table class="newpage-button" style="width: 215px;"]][[row]][[cell style="text-align: center;"]]
[[[[!----]/[!----]noticeboard:[!----]notice/edit/true[!----][!--/tags/notags[!----][!----]/parentPage/noticeboard[!----][!----]|Add a new noticeboard item]]][[/cell]][[/row]][[/table]]

[!----]
[[module CSS]]
@import url(http://snippets.wdfiles.com/local--code/code:newpage-button);
[[/module]]
[!----]

2. Category Autonumbered

2) in the site manager make the noticeboard category autonumbered.

3. Dataform to _template

3) add the following dataform syntax to the noticeboard:_template page:

[[form]]
fields:
  noticetext:
    label: Notice text
    type: text
    width: 100
    height: 5
  download:
    label: Open file
    type: file
  download2:
    label: Open file
    type: file
 download3:
    label: Open file
    type: file
 url:
    label: Related website link
    type: url
    default-schema: http://
[[/form]]

4.Show most recent 5 News entrie

4) On the page where you the notices are to be displayed add the following ListPages module which calls the relevant fields from the dataform. The most recent 5 notices only are displayed:

[[module ListPages category="noticeboard" order="created_at desc" limit="5"]]

+++ %%title_linked%%

%%form_data{noticetext}%%

File: %%form_data{download}%%
File: %%form_data{download2}%% 
Related Website: %%form_data{url}%%
Go to %%linked_title%%
//Posted by RFPG on %%created_at|%e %B %Y%%//

[[div style="border-bottom:2px solid #223773;"]]
[[/div]]
[[/module]]

5. Show "old" News in Summary

You need to use the offset parameter in the ListPage module. So if you are displaying the most recent 5 notices then to display older items than the most recent 5 your offset will be 5, that is it will not include the most recent 5 entries, as in the example below:

[[module ListPages category="noticeboard" perPage="10" order="created_at desc" offset="5" limit="6" separate="false" prependLine="||~ Date ||~ Title ||" appendLine="||||||~ ||"]]
|| %%date|%d/%m/%y%% || %%title_linked%% ||
[[/module]]

Hope that helps.

Thanks to RobElliott for the codes!

Related

Author

RobElliottRobElliott. Please visit his/her userPage.



Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.