How to Customize the Home Page with a Featured News Section
These instructions contain multiple sections and many steps. The instructions are meant to be followed as a whole, section by section, step by step, without logging out of the site between each section.
Add the keyword "featured" to news items
See How to Add Keywords to Plone Content
Create a Smart Folder for Featured News
For more information about Smart Folders, see Smart Folders, "Customizing Your Web Site Manual", p.28.
- From the home page of the Web site, click on the Contents tab
- Click Add Item and select Smart Folder from the drop down list
- Add this metadata:
-
- Short Name - featured
- Title - Featured News
- Description - News that appears on the homepage
- Click the Save button
- Click the Properties tab
- Click in the box next to Exclude from Navigation
- Click the Save button
- Click on the Criteria tab
- In the "Add New Search Criteria" box select Keywords from the Field name drop down list
- Click the Add button
- Under the Criterion details column, under Values, click on the word featured in the existing values list
- Under the Criterion details column, under operator name, click on the radio button and
- Click on the Save button
- In the "Add New Search Criteria" box select State from the Field name drop down list
- Click the Add button
- Under the Criterion details column, under Values, click on the word published in the existing values list
- Click the Save button
- In the "Sort Order" box select Creation Date from the Field name drop down list
- Click in the checkbox under Reverse
- Click the Save button
- Click on State:Private and select Publish from the drop down list
Create a New Homepage Template
- Click on site setup
- Click on Zope Management Interface
- Click on portal_skins (Controls skin behaviour (search order etc))
- Click on plone_content
- Click on document_view (View Document)
- Click on the Customize button
- Click on Custom in the path at the top of the page
- Click in the checkbox next to document_view
- Click the Rename button
- Delete document_view from the text box
- In the text box type:
homepage_view
- Click the OK button
- Click on homepage_view
- In the Title box type:
Home Page View
- Replace all the template text with all of this text: from featured_news_hompage.txt
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <metal:main fill-slot="main"> <tal:main-macro metal:define-macro="main" tal:define="text python: here.CookedBody(stx_level=2)"> <div metal:use-macro="here/document_actions/macros/document_actions"> Document actions (print, sendto etc) </div> <h1 tal:content="object_title" class="documentFirstHeading"> Title or id </h1> <div metal:use-macro="here/document_byline/macros/byline"> Get the byline - contains details about author and modification date. </div> <p class="documentDescription" tal:content="here/Description" tal:condition="here/Description"> Description </p> <p tal:condition="python: not text and is_editable" i18n:translate="no_body_text" class="discreet"> This item does not have any body text, click the edit tab to change it. </p> <div class="stx" tal:condition="text" tal:attributes="class python:test(here.Format() in ('text/structured', 'text/x-rst', ), 'stx', 'plain')"> <div tal:replace="structure text" /> </div> <!-- begin featured news section --> <!-- first, check to make sure the folder exists ... if not, don't display the featured news section --> <div tal:condition="python:test(getattr(here,'featured','FALSE') != 'FALSE')"> <div metal:define-macro="portlet" tal:define="results python:request.get('news', here.featured.queryCatalog());" tal:condition="python:test(template.getId()!='featured' and results, 1, 0)"> <!-- div class="visualClear" --><!-- --><!-- /div --> <fieldset> <legend i18n:translate="label_featured_news_items"> Featured News </legend> <ul class="visualNoMarker"> <tal:newsitems tal:repeat="obj results" tal:define="use_view_action site_properties/typesUseViewActionInListings; parent_url python:here.portal_url();"> <li tal:define=" item_title obj/pretty_title_or_id; item_desc obj/Description; item_type obj/portal_type; item_type_class python: 'contenttype-' + normalizeString(item_type); item_wf_state obj/review_state|python: getInfoFor(item, 'review_state', ''); item_wf_state_class python: 'state-' + normalizeString(item_wf_state); item_url obj/getURL; item_url python:test((item_type in use_view_action), item_url+'/view', item_url)"> <div tal:attributes="class item_type_class"> <a href="" class="" tal:attributes="href item_url; title item_title; class string: portlet-item visualIconPadding" tal:content="item_title">[news]</a> </div> <p class="portlet-item visualIconPadding" tal:condition="item_desc" tal:content="item_desc">[item description]</p> </li> </tal:newsitems> </ul> <br /> <div i18n:translate="label_more_featured_news_items"> <a href="#" tal:condition="python:'featured' in portal.contentIds()" tal:attributes="href string:${utool}/featured" i18n:translate="box_news">More Featured News…</a> </div> </fieldset> </div> </div> <!-- end featured news section --> <div metal:use-macro="here/document_relateditems/macros/relatedItems"> show related items if they exist </div> </tal:main-macro> </metal:main> </body> </html> - Click on the Save Changes button
- Click on the first / in the path name at the top of the page
Add the new template to the list of available views
- Click on portal_types (Controls the available content types in your portal)
- Click on Document (Page)
- Scroll down to the Available View methods
- Put the cursor behind "document_view" in the box
- Press enter
- Type
homepage_view
- Click on the Save Changes button
- Click on the first / in the path name at the top of the page
- Click on the tab called View
- Click on Display and select Home Page View from the drop down list
