To Add the news application to any topic, you can use the following TML:
-
%INCLUDE{"System.NewsApplication"}%
News items can be filtered by category - to set this, change the INCLUDE to
-
%INCLUDE{"System.NewsApplication" CATEGORY="finance"}%
to display News Items from
all categories:
-
%INCLUDE{"System.NewsApplication" CATEGORY="*"}%
urlparams
- ?showfrom and ?showto - dates to filter output between
- ?category - same as CATEGORY filter above
- ?item=FoswikiApplicationData.NewsApplication123 - edit this item inline in the table.
NewsApplicationGroup
If you define the
NewsApplicationGroup? group, they will be the only users that can add new news Items.
Application definition
Latest News
view item format
%STARTSECTION{"view_item"}%| \
%FORMFIELD{"Date" topic="%ITEM%"}% |\
%FORMFIELD{"Message" topic="%ITEM%"}% %FORMFIELD{"Link" topic="%ITEM%"}% | \
%INCLUDE{
"%WEB%.%TOPIC%"
section="%IF{"
'%ITEM%' allows 'CHANGE' AND
context authenticated AND
NOT ((istopic '%USERSWEB%.%TOPIC%Group') AND (NOT '%WIKINAME%' ingroup '%TOPIC%Group'))
" then="edit_button" else="nothing"}%"
warn="off"
}% |%ENDSECTION{"view_item"}%
edit_button
%STARTSECTION{"edit_button"}%[[%SCRIPTURL{view}%/%BASEWEB%/%BASETOPIC%?item=%ITEM%;showfrom=%URLPARAM{"showfrom" default=""}%;showto=%URLPARAM{"showto" default=""}%][%ICON{uweb-bo}%]] %ENDSECTION{"edit_button"}%
edit item format
%STARTSECTION{"edit_item"}%| %STARTFORM{
name="%TOPIC%%BASETOPIC%%CATEGORY%"
action="save"
topic="%IF{"defined 'ITEM'" then="%ITEM%" else="%IF{"defined STOREIN" then="%STOREIN%" else="FoswikiApplicationData"}%.%TOPIC%AUTOINC0000"}%"
method="POST"
redirectto="%BASEWEB%.%BASETOPIC%"
sep=" "
showerrors="off"
}% %IF{"defined 'ITEM'" then="Edit" else="New"}% Item | %FORMELEMENT{
mandatory="on"
format="<span class='formTitle'> $t </span><span class='formValue'> $e $m $h </span>%BR%"
default="%FORMFIELD{"Date" topic="%ITEM%" alttext="%DISPLAYTIME{"$day $month $year"}%"}%"
type="date"
dateformat="%e %b %Y"
name="Date"
title="Date Posted"
size="16"
}% %FORMELEMENT{
mandatory="on"
format="<span class='formTitle'> $t </span><span class='formValue'> $e $m $h </span> %BR%"
default="%FORMFIELD{"Expiry" topic="%ITEM%" alttext="%DISPLAYTIME{"$day $month $year"}%"}%"
type="date"
dateformat="%e %b %Y"
name="Expiry"
title="Expiry date"
size="16"
}% %FORMELEMENT{
mandatory="on"
format="<span class='formTitle'> $t </span><span class='formValue'> $e $m $h </span>%BR%"
default="%FORMFIELD{"Message" topic="%ITEM%" alttext=""}%"
type="text"
name="Message"
title="Message"
size="70"
}% %FORMELEMENT{
format="<span class='formTitle'> $t </span><span class='formValue'> $e $m $h </span>%BR%"
default="%FORMFIELD{"Link" topic="%ITEM%" alttext=""}%"
type="text"
name="Link"
title="Link"
size="70"
}% \
%FORMELEMENT{type="hidden" name="Show" default="%FORMFIELD{"Show" topic="%ITEM%" alttext="show"}%"}% \
%FORMELEMENT{type="hidden" name="Category" default="%FORMFIELD{"Category" topic="%ITEM%" alttext="%CATEGORY%"}%"}% \
%FORMELEMENT{type="hidden" name="formtemplate" default="%WEB%.%TOPIC%"}% \
%FORMELEMENT{type="hidden" name="topicparent" default="%BASEWEB%.%BASETOPIC%"}% \
%FORMELEMENT{type="hidden" name="%IF{"defined 'ITEM'" then="item" else="nothingtoseehere"}%" default="%ITEM%"}% \
%FORMERROR{"%TOPIC%%BASETOPIC%%CATEGORY%"}% | %FORMELEMENT{
name="%TOPIC%%BASETOPIC%%CATEGORY%_submit"
type="submit"
buttonlabel="Submit"
}% \
%IF{"defined 'ITEM'" then="<a class='foswikiButton foswikiCancelButton' href='%SCRIPTURL{view}%/%BASEWEB%/%BASETOPIC%'>Cancel</a>" else=""}% \
%ENDFORM% |%ENDSECTION{"edit_item"}%
widget-news
Side bar widget for WidgetsSkin
-
EDIT="WEB.EditTopic" - set to the topic that the users to to manipulate these news Items, defaults to the System web's NewsApplication (which will lose STOREIN and CATEGORY defaults)
-
LIMIT="2" to show that number of the latest news.
%STARTSECTION{"widget-news"}%<div class="widget-archives widget latnews">
%IF{"
(NOT context authenticated) OR
(NOT '%IF{"defined STOREIN" then="%STOREIN%" else="FoswikiApplicationData"}%.NoTopicWithThisName' allows 'CHANGE') OR
((istopic '%USERSWEB%.%TOPIC%Group') AND (NOT '%WIKINAME%' ingroup '%TOPIC%Group'))
"
then=""
else="<div class='newsApplicationEditLink'>[[%IF{"defined EDIT" then="%EDIT%" else="%WEB%.%TOPIC%"}%][edit]]</div>"
}% <h2 class="widget-header">Latest News</h2>
<div class="widget-content">
%SEARCH{
web="%IF{"defined STOREIN" then="%STOREIN%" else="FoswikiApplicationData"}%"
topic="%TOPIC%*"
"form.name~'%WEB%.%TOPIC%' AND
fields[name='Show'].value = 'show' AND
fields[name='Category'].value ~ '%URLPARAM{"category" default="%CATEGORY%"}%' AND
( d2n(fields[name='Expiry'].value) >= d2n('%DATE%') ) "
type="query"
nonoise="on"
order="formfield(Date)"
limit="%IF{"defined LIMIT" then="%LIMIT%" else="2"}%"
format="<div class='widget-news-item'>$formfield(Message) ... <div class='readMore'>[[$web.$topic][read more]]</div></div>"
}%
</div>
</div>%ENDSECTION{"widget-news"}%
DataForm? definition
Defaults for this topic only