Dec
20
Posted by:
Erik van Ballegoij
12/20/2007 12:11 PM
After so much inspiration from the OpenForce conferences, where Charles Nurse and Vicenç Masanas created advanced versions of the Announcements module, it really felt good creating a new version of the module. Although the number of new features are small, under the hood, a lot has changed.
Let’s review all the changes:
-
Upgrade to VS2005 / ASP.NET 2.0 / WAP. Of course, WAP means Web Application Project in this context. A few months ago, when the discussion between WAP/Compiled and WSP/Dynamic was still hot, I decided to go for the WSP, or Web Site Project, route. Simply because that would allow a lot more users to start working with the code. However, the second time around, a few weeks ago, when I restarted the project, I decided to begin from scratch, and go for the WAP model. The main reason for this is to allow for alternate dataproviders.
-
Full support for core token replace functionality. When I was first looking at the token replace functionality, it looked very promising, but using it would cause compatibility problems in the templating system. Because of the old [ObjectName:Propertyname|formatstring] syntax, I would have had to use a specific object name for the announcements module. Tokens such as [TITLE] would stop working.
As luck would have it, work on the language selector made it necessary to create an object less token replace syntax. So now, we can just use [PropertyName|FormatString] as token, or in abbreviated form, just [PropertyName].
On top of this, also all core tokens are supported (depending on access rights of course), so you could just as easily add [Portal:Portalname] to your template, in order to display the portal name with every announcement. Please check Stefan Cullman's blog for more info on the core tokenreplace functionality:
http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1547/Default.aspx
-
- A full change log is available here: http://support.dotnetnuke.com/project/ChangeLog.aspx?PROJID=8
Speed
The most visible change is of course the change in the templating system. The 03.04.00 version of the module used an ASP.NET Datalist with a literal control in the itemtemplate. The onDataItemBound event was used to “render” every item in the datalist. In the new version of the module, the output is rendered directly by overriding the ASP.NET Render() method, which renders the complete list. Apart from being more flexible and cleaner, this is also a lot faster. I just did a small, completely unscientific, speed test between the 03.04.00 version and the 04.00.00 version of the module.
In this test I added 112 announcements to the module, and a timer on the page (I used Scott McCulloch’s very useful PageGenerated skinobject, you can find that on his site,
www.ventrian.com). After 20 something tests, the average page generation time for a page with the old module was 0.115 seconds, and for the new module 0.0054 seconds. In this test the new module was 20 times faster!
Syntax changes
The syntax for the templates has not been changed, however, it is important to note that you must make sure you have an [EDIT] token in the template, otherwise you won’t be able to edit announcements after they are created.
Other new tokens are: [RAWIMAGE], [READMORE]. RAWIMAGE will render just the url to the announcement image, allowing you to use that image to build your own image tag (or even to put it in an inline style definition). READMORE is used to display the “read more” link at the end of an announcement. The old “MORE” token also still works, but that will only render the text “read more…”. READMORE will render the complete link, and will hide itself when there is no link present. Due to the changes in the way templating works, the MORE token cannot hide itself anymore….
Complete Token List
|
[EDIT]
|
This will render an edit pencil, if, and only if, the logged on user had edit rights for the module. You MUST add this token to the Item Template (and alternate item template if you are using that), in order to be able to edit items
|
|
[ITEMID]
|
This will render the item id of the announcement
|
|
[MODULEID]
|
This will render the module id of the module the announcement belongs to
|
|
[CREATEDBYUSER]
|
This will display the display name of the user that created the Announcement. NOTE: on sites with many users adding this token to a template will cause a performance hit, as for every Announcement a user record has to be found and displayed. Many announcements and many users will cause a large amount of extra database hits.
|
|
[CREATEDDATE]
|
This will show the item creation date, in localized long date forum
|
|
[DESCRIPTION]
|
This will display the announcement discription
|
|
[EXPIREDATE]
|
This will display the announcements expire date
|
|
[RAWIMAGE]
|
Thsi will display the raw image url
|
|
[IMAGESOURCE]
|
This will display the announcement image as defined in the announcement. A complete image tag will be rendered
|
|
[MODULEID]
|
This will display the moduleid of the module.
TIP: You could use this value to use a module specific css classname, for instance like this:
<span class="SubHead_[MODULEID]">[TITLE]</span>
|
|
[MORE]
|
This will display the "read more..." text, without hyperlink. A full read more hyperlink would look like this:
<a href="[URL]" target="[NEWWINDOW]">[MORE]</a>
|
|
[READMORE]
|
This will display a complete "read more..." link. If no url is defined in the announcement, no link will be rendered
|
|
[NEWWINDOW]
|
This token can be used to open the link in a new window, based on the selection made in the announcement, for example:
<a href="[URL]" target="[NEWWINDOW]">[MORE]</a>
|
|
[PUBLISHDATE]
|
This will show the item publish date, in localized long date forum
|
|
[TITLE]
|
This will display the announcement title
|
|
[TRACKCLICKS]
|
This will render "Yes" or "No", depending on whether to track clicks or not
|
|
[URL]
|
This will display the url the announcement should point to. In order to use this url as a clickable hyperlink, use something like this:
<a href="[URL]">[MORE]</a>
|
|
[VIEWORDER]
|
This will show the view order of the item
|
New Default Templates
|
Header Template
|
<table class="DNN_ANN_DesignTable" cellspacing="0" Summary="Announcements Design Table" border="0" style="border-collapse:collapse;"><tr><td>
|
|
Item Template
|
<table><tr><td>[IMAGESOURCE]</td><td valign="top"><span class="SubHead">[EDIT][TITLE] - [PUBLISHDATE]</span><div class="Normal DNN_ANN_Description">[DESCRIPTION] [READMORE]</div></td></tr></table>
|
|
Alternate Item Template
|
(empty default)
|
|
Separator Template
|
(empty default)
|
|
Footer Template
|
</td></tr></table>
|
Tags:
Re: Announcements module: version 4 is here!
Will this be included in 4.8?? Thank you, Tom
By tlyczko on
12/27/2007 8:22 PM
|
Re: Announcements module: version 4 is here!
erik, nice enhancements.
By bbhermann on
12/27/2007 8:22 PM
|
Re: Announcements module: version 4 is here!
Erik, can you post an example for Date Formatting token replace?
By greenflash on
1/31/2008 2:49 PM
|
Re: Announcements module: version 4 is here!
Is is possible to download the source code for 3.04.00 version ?
By bastos_maumau on
1/31/2008 2:49 PM
|
Re: Announcements module: version 4 is here!
good module ,but some basic things are missing there is no date format function
By vipin_josea on
1/31/2008 2:49 PM
|
Re: Announcements module: version 4 is here!
@Greenflash and vipin_josea: the module supports date formatting through the core token replace functionality. Please check out Stefan Cullmanns blog for samples: http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1547/Default.aspx (as also mentioned in this blog post btw!)
By ErikVB on
1/31/2008 2:52 PM
|
Re: Announcements module: version 4 is here!
@bastos_maumo: yes, just go to the projects download page. Check this blog if you are not able to find the sources: http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1150/Default.aspx. Mind you: you need vs2003 and dnn 3.3.7 to modify the module!
By ErikVB on
1/31/2008 2:55 PM
|