AW: [opencms-dev] Examples of news and navigation with jsp.

Mark Miller mark.miller at hema.ch
Mon Dec 1 09:13:01 CET 2003


Hi ,

Something like this (below) .... although here I am getting the news id
from a property. If you want to loop through all news items then get the
NewsChannelContentDefinition object. See the documentation for this
class, or search the mailing archive. Stuff has been posted on this
previously.

The other channels have nothing to do with the News modules and again,
if you search the archive ... Alex wrote some stuff on these.

There is currently no way to change the permissions on news channels.

All the best,

mark

********************************************

<%@ page session="false" import="java.util.*" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="com.opencms.flex.jsp.*" %>
<%@ page import="com.opencms.modules.homepage.news.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<!doctype html public "-//W3C//DTD HTML 4.01 Translational//EN">

<cms:template element="head">
  <cms:include file="/system/modules/ch.hema.www/jsptemplates/hema.jsp"
element="head"/>
</cms:template>

<cms:template element="body">
<%
  NewsContentDefinition newsCD;

  // Create a JSP action and object elements
  com.opencms.flex.jsp.CmsJspActionElement cms= new
CmsJspActionElement(pageContext, request, response);
  com.opencms.file.CmsObject cmsObject = cms.getCmsObject();

  int newsId = 0;
  try {
    newsId = Integer.parseInt(cms.property("Description", null, "0"));
  }
  catch(NumberFormatException e) { out.println("Exception : while
setting properties : "+e); }
%>
<!-- Begin Page Content -->
<table cellpadding='0' cellspacing='0' border='0' class='newsEDVTable'>
<%      
  try {
    newsCD = new NewsContentDefinition(cmsObject, new Integer(newsId));

    // Get link text and url
    String linkText = newsCD.getLinkText();
    String linkURL = newsCD.getLink();
    if (linkURL.indexOf("http://") == -1) {linkURL =
cms.link(newsCD.getLink());}
    if (linkText == null) {linkText = linkURL;}

    // Print the headline
    out.println("<tr>");
    out.println("<td align='left' valign='center' class='EDVNews'><h4
class='newsEDVTitle'>"+newsCD.getHeadline().toLowerCase()+"</h4>");
    if (newsCD.getLink() != null) {out.println("<a href='"+linkURL+"'
target=_blank>"+linkText.toLowerCase()+"</a>");}
    out.println("</td>");
    out.println("<td align='right' valign='top' class='EDVNews'><a
href='http://www.heise.de' target=_blank><img
src='"+cms.link("/system/modules/ch.hema.www/resources/images/heise.jpg"
)+"' border='0'></a></td>");
    out.println("</tr>\n");

    out.println("<tr><td align='left' class='newsEDV'
colspan='2'>"+newsCD.getDate().toLowerCase()+" :
"+newsCD.getDescription().toLowerCase()+"</td></tr>\n");

    // Print spacer
    out.println("<tr><td colspan='2'><hr></td></tr>");

    // Print the content
    String contentText =
newsCD.getText().replaceAll("\r\n","\n").replaceAll("\n","<br>\r\n");
    out.println("<tr><td colspan='2' align='left'
class='newsEDV'>"+contentText.toLowerCase()+"</td></tr>\n");

    // Print spacer
    out.println("<tr><td colspan='2'><hr></td></tr>");

    // Print author
    out.println("<tr><td colspan='2'><table width='100%' cellpadding='0'
cellspacing='0' border='0'><tr><td align='left' class='newsEDV'><a
href='"+cms.link("/system/modules/ch.hema.www/www/edvnews.html")+"'>edv
news archive</a></td>");
    out.println("<td align='right' class='newsEDVSmall'>published by :
"+newsCD.getAuthor()+"</td></tr></table></td></tr>");
  } catch (Exception e) { out.println("<tr><td colspan='2'> Exception :
while setting news item : "+e+"</td></tr>"); }

%>
</table>
</cms:template>

<cms:template element="foot">
  <cms:include file="/system/modules/ch.hema.www/jsptemplates/hema.jsp"
element="foot"/>
</cms:template>

-----Ursprüngliche Nachricht-----
Von: opencms-dev-admin at opencms.org
[mailto:opencms-dev-admin at opencms.org] Im Auftrag von Salvador Santander
Gesendet: 01 December 2003 09:02
An: OpenCMS list (E-mail)
Betreff: [opencms-dev] Examples of news and navigation with jsp.

Hello, list. Anybody can send me a simple example of how to show the
news
with jsp?
And another example of navigation?
Thanks very much.

_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please
visit
http://mail.opencms.org/mailman/listinfo/opencms-dev






More information about the opencms-dev mailing list