Articles FAQ A TRADUIRE

Contents


News Detail on a New Page

If you would like news articles to appear on a new page, rather then in the same page as the news summary, simply add the detailpage option to your {news} parameter.
From the {news} help:
(optional) detailpage="pagealias" - Page to display News details in. This can either be a page alias or an id. Used to allow details to be displayed in a different template from the summary.
Example:
  {news category="Articles" number="1" detailpage="Articles"}
Now go to Content/Pages/Add New Content and, in the example above, create a page called "Articles", and that page will be called upon to show the details of a news item.
Important: :Make sure that the template used by your detailpage has the tag {content} in it. The news detail will output in the {content} area. If you do not put {content} in the page template you will not see the news detail on this page.

Hide Empty News Block

Author: Cyrus Elder
Here is one way to make the news block or news header only appear if there is a news item to display. This comes in handy in situations where you have created a per page news categories or would just like the news block to appear and disappear automatically. In short this is achieved by removing the NEWS header from the site template and inserting it into the news summary template along with a bit of smarty code to determine if there are any news items to display.
Here is the news block as it is presented in one of the default templates. Here you can see the news module tag is called after News header is displayed.
  <!-- Start News -->
  <div id="news">
    '''<h2>News</h2>'''
    {news limit=3 detailpage='news'}
  </div>
  <!-- End News -->
In this situation the news header is displayed regardless if there is news to display.
We can change this by removing the news header from the template.
  <!-- Start News -->
    <div id="news">
      {news limit=3 detailpage='news'}
    </div>
  <!-- End News -->
After saving these changes to the site template we will now add some code to the news summary template which can be found in news module under the summary template tab. What we will be adding is an if conditional that checks that there is a news item to display, if there is no news to display then the news block is just skipped over.
First we add the following lines to the top of the summary template. Note: additions are in bold.
  <!-- Start News Display Template -->
  '''{ if isset ($items[0]) } 
    <h2>News</h2>'''
  {foreach from=$items item=entry}


  <div class="NewsSummary">

  {if $entry->formatpostdate}
	<div class="NewsSummaryPostdate">
		{$entry->formatpostdate}
	</div>
Then at the end of the summary template we add the following to close the if loop.
  {else if $entry->content}

	<div class="NewsSummaryContent">
		{eval var=$entry->content}
	</div>
  {/if}

  </div>
  {/foreach}
  '''{/if}'''

  <!-- End News Display Template -->
What we have done here in simple terms is changed the script so that it checks to see if any news items exist, if no news items exist then we skip over the entire news block, which now includes the news header. Therefore if there is no news to display, you will not see the news block. On the other hand if there is news to display it will create the news block just as it did before we made these changes.

News catagory Per Page

News can be configured so that different news items are displayed on each page. IE. team 1's page displays news for team 1, team 2's page shows news for team 2 etc. etc. In short this can be achieved by going to the page template and adding a category parameter to the news tag and assigning the $page_alias variable to it. Then create a news category with the same name as the page alias of the page you would like to display the news on.
Page alias.jpg
First we will make note of the page alias of the page you would like to add news too. The page alias can be found under the options tab when your are editing a content item. Be aware that the options available to you when editing content will change depending on the content type chosen.


Create newscat.jpg
Next we will go to the news module and create a category and name it the same as the page alias of the page we want the news displayed on. After creating the news category you should add atleast one news story to the category you created in order to test that everything is working correctly.


Next we will want to go to the page template and find the tag which loads the news module.
The default will look something like this.
  <!-- Start News -->
    <div id="news">
      <h2>News</h2>
      {news limit=3 detailpage='news'}
    </div>
  <!-- End News -->
Now we want to change the news tag to include the category parameter and assign the page alias variable as the category.
  <!-- Start News -->
    <div id="news">
      <h2>News</h2>
      {news limit=3 detailpage='news' category = $page_alias}
    </div>
  <!-- End News -->
Once complete you should only be presented with news items that are assigned to the news category that corresponds to the page alias.
After making these changes you may find it helpfull to also make it so the news block only appears if there is news to display. Instructions how to do this can be found in "Hide Empty News Block" on this page.

How to use CAPTCHA with News Modules

In order for Captcha to work, it needs to be installed.
Install Captcha
Login to your CMSMS admin control panel.
Go to Extensions / Modules in the top menu bar.
You should be able to see CAPTCHA in the left column.
To the right are other columns, one called ACTION. Click the INSTALL link beside Captcha.
It is now installed.
News Module
News Module is automatically installed when you first install CMSMS.
Install Comments Module
You are already in your CMSMS admin control panel.
Go to Extensions / Modules in the top menu bar.
You should be able to see COMMENTS in the left column.
To the right are other columns, one called ACTION. Click the INSTALL link.
It is now installed.
ADDING Comments to News
Go to Content / News in the top menu bar.
You will see 5 tabs across the top of the page:
Articles | Category | Summary | Detail | Options
By clicking on each of these tabs, you can perform tasks and manipulate the way the results will appear on your web pages.
Click the Detail tab
This is the TEMPLATE for how the News will look, with all details showing.
Scroll to the bottom of the template, at the end of the final {if} statement, click and press Return to go to a new line."
Type some CMSMS code like this, making changes to add or remove whatever you need:
{cms_module module="comments" modulename="News" category="Articles" pageid=$entry->id emailfield=1 websitefield=1 spamprotect=1 notify="you@an-email-name-of-your-choice-dot-com"}
What do all those codes mean?
  • modulename="News - details which Module is being used
  • pageid=$entry->id - details which page the comment is on, so it won't show up on every page
  • emailfield=1 - allows an email address, which will not be readable by spam bots or harvesters
  • websitefield=1 - allows a website URL to be added
  • spamprotect=1 - ensures the Captcha characters must be entered on the screen, to prevent email name harvesting.


If you're not sure what to change, only change [1] the email name to yours (for testing), and [2] if you don't have Categories set up yet, you may remove the category="Articles" bit.
Click the Submit button to save changes.
Final touches!
In the top menu, go to Content / Comments
You will see 3 tabs : Comments | Comments Display Template | Options
Comments is where NEW comments will appear - if you put your email name in the Notify Field further down this page, you will be notified when a new comment has been posted.
Comments Display Template is the template which displays the way the Comments appear on the screen. Leave this as is for the moment.
Options is the juicy bit :) Put a check mark [or a tick mark] beside SPAM PROTECT and MODERATE [Moderate allows you to be notified of new comments, so you can approve them before they appear on the webpage]
In the NOTIFY field you can type your email address where notifications will be sent.
Click the Submit button.
Last step!
In the top menu, go to Site Admin / Global Settings.
There is a button called CLEAR for 'Clear Cache' - click it once.
The next field is File Creation Mask (umask): - change this from 022 to 002
Scroll down and click the Submit button.
To test your hard work
In the top menu, click on Content / News. You are going to add a quick News item.
  • Click the tab called CATEGORIES.
  • Click the link 'Add Category', type NEWS.
  • Click the Submit button.
  • Now click the tab called ARTICLES.
  • Click the link 'Add Article' and type some text in the Summary and Detail text boxes.
  • Select NEWS as the Category from the popup list.
  • Click the Submit button.


Now - go to your 'live' site and view the News item you just added.
  • At the bottom of the item should be a link called COMMENT.
  • Click this link.


You should now see a little Comments form to fill in and you should be able to see CAPTCHA in action.
Well done!
Troubleshooting
Server/location move
After a server or directory move, the module won't work anymore (some path gets broken...). Go to Administration, click on Extensions / Modules, select 'Uninstall' option for Captcha, then "Install' it again... voilà!
Additional details can be found here
  • In your CMSMS admin panel, click on Extensions / Modules / Captcha
  • Click the HELP link at the top of the page.
  • See http://www.wikipedia.org/wiki/Captcha for more information about Captcha challenge-response tests.


WebGirl 00:33, 21 January 2007 (CST)


This page in: English - Deutsch - Español - Français - Italiano - Lietuvių - Nederlands - Norsk - Polski - Česky - Русский - Svenska - Tiếng Việt - عربي - 日本語 简体中文

User Handbook/Admin Panel/Content/News/Templates/News Detail on New Page/fr

From CMSMS

Arvixe - A CMSMS Partner