[opencms-dev] Is it possible to include titles and links from other pages into a page?

M Butcher mbutcher at grcomputing.net
Fri Aug 29 20:51:02 CEST 2003


You will probably have to write a little bit of JSP Java to do this, but
I think that all you'd have to do is get the navigation for those
directories.

If you haven't already read the documentation on the JSP script objects
(CmsJspActionElement, CmsNavElement, etc.) you will probably want to use
that. Here's a script that prints all of the links inside a directory. I
use it to create navigation bars (Note: change ROOT_NAV_CONTEXT to your
dir):

<%@ page import="java.util.*, com.opencms.flex.jsp.*" %>
<%
/*
 * Author: M Butcher (mbutcher at AT@grcomputing at DOT@net)
 * License: GPL v.2 or higher (at your option)
 */
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);

// This is where the menu should start building.
String ROOT_NAV_CONTEXT = "/my_vfs_dir/";

String filename = cms.getRequestContext().getUri();
String foldername = com.opencms.file.CmsFile.getPath(filename);

ArrayList navItems =
cms.getNavigation().getNavigationForFolder(ROOT_NAV_CONTEXT);
Iterator i = navItems.iterator();

while (i.hasNext()) {
    CmsJspNavElement ne = (CmsJspNavElement)i.next();
    String neName = ne.getResourceName();
    if(neName.equals(foldername)) {
        out.println("<span class=\"main-menu-link-followed\">" +
ne.getTitle() + "</span><br>");
    } else {
        out.println("<a class=\"main-menu-link\" href=\"" +
cms.link(neName)+"\">");
        out.println(ne.getTitle() + "</a><br>");
    }
}

/*
// If you uncomment this section, it will also conditionally add a link
// to the home page -- nice if you are doing a menu.
if(!"/".equals(foldername)) {
    out.println("<p class=\"main-menu-home\">");
    out.println("<a class=\"main-menu-home-link\" href=\""+cms.link("/")
      + "\">Home</a></p>");
}
*/

%>

Hope that helps,

Matt

On Fri, 2003-08-29 at 05:27, Matthew Evans wrote:
> Hi, 
> 
> I'm just starting a site with OpenCMS and I've been through all the jsp
> tutorials.
> It seems like theres going to be a lot of JSP includes going on in my site.
> 
> I want to have a page that lists all the recent newsletters sent from my
> site.
> Each newsletter is going to be stored in openCMS as an HTML page in a
> "newsletter" directory.
> 
> I then want a "newsletters" page to have a dynamically generated list of
> links to view all the previous newsletters held in the newsletter directory.
> 
> In other CMS's I've been able to do this with tags in the jsp like:
> <cms:articles type="newsletters">
> <cms:article asset="description"/>
> </cms:articles>
> 
> I can't see a way of doing this easily in OpenCMS though.
> Any ideas?
> 
> Thanks.
> 
> M at .
> 
> 
>  
> Matthew Evans
> SolidStateGroup
> tel. +44 (0) 20 77402133
> Mob. +44(0)7958 379562
> http://www.solidstategroup.com
> 
> _______________________________________________
> 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
-- 
M Butcher <mbutcher at grcomputing.net>



More information about the opencms-dev mailing list