Skip to content

nan

Sections
Personal tools
You are here: Home » How Tos » How to add a News Folder   newsfoder
Log in
No Software Patents!

Under the influence of the patent system and big industry lobbyists, the European Union is on the verge of making a huge mistake: to pass a law that would legalize software patents.

 

How to add a News Folder

Document Actions
Sometimes you want your users only to add contents of a certain type at a specific location or you want to display another icon for an specific (type of) Folder, or you want to display certain hirarchies of News.

This is (I think) the simplest possible folderish type. You will need about 10 minutes to implement it. This howto demonstrates how easy it is to implement your own types in Plone.

A NewsFolder? is a folderish type which displays news hierarchically.

A product version is available for download on maenner-club.de

The current developement version is available in the collective cvs.

Implemetation

DO NOT TEST ON PRODUCTION SITES! Backup your data.fs! Allthough this is simple enough, try it on a test site first, make sure it works, and then implement it on your production site.

OK having said this, lets get started. In the ZMI goto your SiteRoot? and open portal_types. Add a Factory-based Type. Id: NewsFolder?, Use default type information: ArcheTypes SimpleFolder (or just Plone Folder).

Go to your newly created NewsFolder? Type. Alter the title, description and icon.

Select News, Images and NewsFolder? as Allowed content types and check Filter content types?.

Now you want your NewsFolder? to show the News. Select the actions tab of your NewsFolder?. In the (topmost) Action with id view change the Action from base_view to sdnews.

To get the sdnews.pt we will have to customize the news template. Goto /portal_skins/plone_templates/news and click the customize button. Rename the template to sdnews.

Add a NewsFolder? to your Site (with id Newsitems or something like this). when you open that Folder you will see that it displays (all) your news.

Next we only want to display only the news in the current folder (and sub-folders)

we change:

  <div metal:fill-slot="main"
tal:define="results python:container.portal_catalog(meta_type='NewsItem',sort_on='created',sort_order='reverse',review_state='published');
Batch python:modules['Products.CMFPlone'].Batch;
DateTime python:modules['DateTime'].DateTime;
b_start python:request.get('b_start',0);">

to :

  <div metal:fill-slot="main"
tal:define="results python:container.portal_catalog(meta_type='NewsItem',sort_on='created',sort_order='reverse',review_state='published',path='/'.join(here.getPhysicalPath()));
Batch python:modules['Products.CMFPlone'].Batch;
DateTime python:modules['DateTime'].DateTime;
b_start python:request.get('b_start',0);">

Adding images to your news categories.

In each NewsFolder? you created put an image named NewsImage.png. To display the category you're in at the Top of your Newslisting add the image to your description

ie:

  <table width="100%">
<tr> <td>
<div tal:content="here/Description" class="description">The latest news, sorted in reverse chronological order.</div>
</td> <td>
<img tal:attributes="src string:${here/absolute_url}/NewsImage.png" alt =""/>
</td>
<td tal:condition="not:here/portal_membership/isAnonymousUser">
<div class="field">
<form name="quickAdd" action="createObject" method="post">
<input name="type_name" type="hidden" value="News Item"/>
<input class="standalone" type="submit" value="Neue Nachricht" tabindex="2"/>
</form>
</div>
</td>
</tr>
</table>

Left to the description of the newstopic the NewsImage? of the NewsFolder? it is in will be displayed by :

   <h2 tal:content="result/Title">
Title
</h2>
<table>
<tr> <td>
<a tal:attributes="href string:${resultObject/absolute_url}/..">
<img tal:attributes="src string:${resultObject/absolute_url}/../NewsImage.png"/>
</a>
</td> <td>
<p tal:content="structure result/Description">
Description
</p>
</td> </tr>
</table>

Note that the image has a link to the Newsfolder, in which the NewsItem? resides. This way you can filter your news per category.

I am not quite happy with the .. links. There must be another (more plonish) way to determine the folder, but I just did not find out how :(. If somebody could enlighten me on this.

If you want to display the NewsImage? in your NewsItem? as well you have to customize your newsitem_view.pt :

       <table>
<tr> <td>
<img tal:attributes="src string:${here/absolute_url}/NewsImage.png"/>
</td> <td>
<span class="description" tal:content="here/Description">
News summary
</span>
</td> </tr>
</table>

Displaing sdnews as your frontpage:

simply add an DTML Document named index_html to your siteroot :

  <dtml-var sdnews>

Thats all folks. happy sdoting :)

Related readings:

[More HowTos by nan]?

How to create a ''search only this folder'' option

Setting up CMFBoard as the dicussion tool

See it in action on www.trashpicts.com (plone 1) or maenner-club.de (plone 2)

Further readings:

MySite Tutorial an excellent introduction to product development for Plone for site managers


comments:

Great Job --CMYanko?, Tue, 27 Apr 2004 12:36:27 -0500 reply
This is a hot idiom. One that I'm sure I'll employ in the near future. Thanks.

Great Job --nan, Sat, 01 May 2004 18:03:17 -0500 reply
you are welcome ;)

This worked but....special news items show up in "news" tab --tcape, Sun, 02 May 2004 18:12:15 -0500 reply
Now all my "special news items" show up in the regular "new" tab too! How do I make my special news show up only in the special news folder?

This worked but....special news items show up in "news" tab --nan, Mon, 03 May 2004 11:15:20 -0500 reply
Read: RepurposingOfPortalTypes Build your own specialNewsItem and change sdnews-pt to display this type.

Product version --nan, Sat, 04 Sep 2004 05:22:19 -0500 reply
If you use the Product version you do not have to follow the steps described in this howto, you may just install it as any other product, it should work out of the Box.

The reason this Howto still is online is to demonstrate how one can develop products without having access to the Filesystem (usefull if you have an account on a free Plone hosting like objectis)

Created by nan
Last modified 2004-12-15 05:30 PM
« December 2008 »
Su Mo Tu We Th Fr Sa
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
 
 

Powered by Plone

This site conforms to the following standards: