Personal tools
You are here: Home Python How to add a new News Type in Plone
Document Actions

How to add a new News Type in Plone

last modified 2006-02-22 03:49 PM

Many times in a Plone site, you want to add different types of News sections, each with their own separate tab. Here's how you do it.

We will use the example of the "Python" news type which is actually this section of the site!

Step 0

Log into the Zope Management Interface (ZMI):
e.g.
http://www.fourm.info/manage

You will get normal Plone login. Make sure your username has manager priveleges. This is set in the acl_users folder (for future reference).

Step 1

Create the Portal Type.

1. In the ZMI click on portal_types
2. check "News Item"
3. hit copy button
4. hit paste button
5. check copy_of_News Item
6. hit rename button
7. give it new name e.g. "Python Item"
8. hit ok button
9. click on the new type you added "Python Item"
10. in Description chance "New" to "Python" Do not change the meta type. If you leave it as a News Item you can keep the normal News box for the welcome tab and so let visitors see news items of any sort as they get added to various tabbed sections of site.
11. click save changes

Step 2

Add new Portal Type to Content Type Registry

1. in the ZMI click on Root Folder
2. click on Content Type Registry
3. in the blank section add the information with the pull down menu choose Extension then hit add:
Add predicate:python Extension
4. with pull-down menu choose the new type, e.g. "Python Item", In the blank section after Extensions: add the name e.g. "python" and then hit change button
5. move it up to where you want it in list

Step 3

Add new template for the new portal type.

1. In ZMI choose portal_skins then plone_templates
2. Click on "news" template
3. Click on customize (this is how you copy any skin template into the Custom folder)
4. Change line (changes are in bold):
tal:define="results python:container.portal_catalog(meta_type='News Item',
sort_on='created',sort_order='reverse',review_state='published');

tal:define="results python:container.portal_catalog(portal_type='Python Item',
sort_on='created',sort_order='reverse',review_state='published');

5. Change line (changes are in bold):
<h1 i18n:translate="heading_news">News</h1>

<h1 i18n:translate="heading_news">Python World</h1>

6. Change line (changes are in bold):
 <div i18n:translate="description_news" class="description">
The latest news, sorted in reverse chronological order.</div>

<div i18n:translate="description_news" class="description">
This section contains tips about Python and Plone programming from someone
just learning the ropes.
</div>

7. Click on save changes button
8. Go up a level to Custom folder
9. Check news template
10. Click on rename button and change name to e.g. "python"

Step 4

Add new ui slot for the new portal type.

1. In ZMI choose portal_skins then plone_templates then ui_slots
2. Click on "news_slot" template
3. Click on customize (this is how you copy any skin template into the Custom folder)
4. Change line (changes are in bold):
 tal:define="results python:request.get('news', 
here.portal_catalog.searchResults( meta_type='News Item'
, sort_on='Date'
, sort_order='reverse'
, review_state='published')[:5]);"

tal:define="results python:request.get('news',
here.portal_catalog.searchResults( portal_type='Python Item'
, sort_on='Date'
, sort_order='reverse'
, review_state='published')[:5]);"

5. Change line (changes are in bold):
 <h5 i18n:translate="box_news">News</h5>

<h5 i18n:translate="box_news">Python World</h5>

6. Click on save changes button
7. Go up a level to Custom folder
8. Check news_slot template
9. Click on rename button and change name to e.g. "python_slot"

Step 5

At top level add a new Plone folder

1. In ZMI got to Root Folder and click on pull down menu and choosing Plone Content.
2. click add
3. click on Plone Folder
4. choose name, e.g. "Python"
5. click add

Step 6

Create index_html for new folder

1. In ZMI click on folder created in Step 5 You'll see: "There are currently no items in Python"
2. in pull down menu goto DTML_Method and click add button
3. in the blank sections add the information for new DTML_Method and hit add
Id
index_html

Title
Python

4. Click on index_html and delete the text in the file box. Replace it with this one line and hit save changes button:
<dtml-return python>


Step 7

Set up news box slot for the folder. Tip: this is the general way you can have different tabs have different slots than the default.

1. In ZMI click on folder you created in step 5.
2. Click on Properties tab
3. Fill in Information for 2 new properties and then hit add for each:
Name left_slots  type  lines

Name  right_slots type  lines

4. In each of the empty slots sections, add the left and right slots you want and click on save changes. Just make sure that one of them is the slot you created in Step 4:


right_slots

here/workflow_review_slot/macros/review_box
here/calendar_slot/macros/calendarBox>
here/related_slot/macros/relatedBox
left_slots here/navigation_tree_slot/macros/navigationBox here/python_slot/macros/newsBox


Step 8

Add Portal Action for new type

1. In ZMI go to Portal Actions.
2. In the blank section fill in the information for the new tab and hit add:
Name
Python World
Id
python
Action
string:$portal_url/Python
Condition
[leave blank]
Permission 
View
Category
portal_tabs
Visible?

3. Move it into place. Trick Check all the actions you want to appear after the new one and then hit the move down button. The new action falls into place in one fell swoop.

Step 9

Adding Content

Now when you go to the site you will see the new tab you created. Click on it, switch to "Content View" and add an object of the new type you just created.  Note you only have to add a Title. The Name will be created automatically. Voila.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: