Personal tools
You are here: Home Library Development SILO Web Service How-Tos News and Events How to Customize the Home Page with a Featured News Section
Document Actions

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.

  1. From the home page of the Web site, click on the Contents tab
  2. Click Add Item and select Smart Folder from the drop down list
  3. Add this metadata:
    • Short Name - featured
    • Title - Featured News
    • Description - News that appears on the homepage
  4. Click the Save button
  5. Click the Properties tab
  6. Click in the box next to Exclude from Navigation
  7. Click the Save button
  8. Click on the Criteria tab
  9. In the "Add New Search Criteria" box select Keywords from the Field name drop down list
  10. Click the Add button
  11. Under the Criterion details column, under Values, click on the word featured in the existing values list
  12. Under the Criterion details column, under operator name, click on the radio button and
  13. Click on the Save button
  14. In the "Add New Search Criteria" box select State from the Field name drop down list
  15. Click the Add button
  16. Under the Criterion details column, under Values, click on the word published in the existing values list
  17. Click the Save button
  18. In the "Sort Order" box select Creation Date from the Field name drop down list
  19. Click in the checkbox under Reverse
  20. Click the Save button
  21. Click on State:Private and select Publish from the drop down list

 

Create a New Homepage Template

  1. Click on site setup
  2. Click on Zope Management Interface
  3. Click on portal_skins (Controls skin behaviour (search order etc))
  4. Click on plone_content
  5. Click on document_view (View Document)
  6. Click on the Customize button
  7. Click on Custom in the path at the top of the page
  8. Click in the checkbox next to document_view
  9. Click the Rename button
  10. Delete document_view from the text box
  11. In the text box type:
    homepage_view
    
  12. Click the OK button
  13. Click on homepage_view
  14. In the Title box type:
    Home Page View
    
  15. 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>
  16. Click on the Save Changes button
  17. Click on the first / in the path name at the top of the page

Add the new template to the list of available views

  1. Click on portal_types (Controls the available content types in your portal)
  2. Click on Document (Page)
  3. Scroll down to the Available View methods
  4. Put the cursor behind "document_view" in the box
  5. Press enter
  6. Type
    homepage_view
    
  7. Click on the Save Changes button
  8. Click on the first / in the path name at the top of the page
  9. Click on the tab called View
  10. Click on Display and select Home Page View from the drop down list

Related Sites
  • Plone How-To: Using Topics and Smart Folders

    A detailed technical description of topics and smart folders in Plone. Some of this information is out of date as topics are no longer supported in Plone 2.5. The description of smart folders, the tips, and the examples are still relevant to Plone 2.5.

  • The Definitive Guide To Plone: Introducing Basic Plone Templating

    A chapter from "The Definitive Guide To Plone" that describes the template systems available in Plone including TALES and TAL. This book describes templates used in Plone 2.0, so the examples provided may differ slightly from your PLOW site based on Plone 2.5.1.

Last modified May 02, 2008 12:58 PM
« December 2008 »
Sun Mon Tue Wed Thu Fri Sat
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