AW: AW: [opencms-dev] how to include a link content ??

Prestel Marianne m.prestel at akap.de
Mon Aug 11 09:49:02 CEST 2003


Hi Matt,

thanks a lot. It's really great. It's exactly what I've been looking for!!!

Regards Marianne

-----Ursprüngliche Nachricht-----
Von: M Butcher [mailto:mbutcher at grcomputing.net]
Gesendet: Freitag, 8. August 2003 22:18
An: opencms-dev at opencms.org
Betreff: Re: AW: [opencms-dev] how to include a link content ??


Marianne,

I did something similar, though it is pretty rudimentary. To call the
page, I did something like
<cms:include ...>
  <cms:parameter name="download_dir">/my/downloads/</cms:parameter>
</cms:include>

Feel free to use whatever you can from the code here.

Matt

-------------------------------

<%@ page import="java.util.*,
com.opencms.flex.jsp.*,com.opencms.file.CmsObject,
com.opencms.file.CmsFile" %>
<%-- Downloads Table --%>
<table width="100%" class="downloads-table">
  <tr class="downloads-header">
    <th class="downloads-th">Name</th>
    <th class="downloads-th">File Type</th>
    <th class="downloads-th">File Size</th>
  </tr>
<%
/*
 * @author mbutcher at grcomputing
 * @license GPL v2
 *
 * This script provides a listing of downloads in a particular
directory. Any file with read 
 * permissions will be considered "downloadable". 
 * 
 * PARAMETERS:
 * download_dir: the directory in which the files are stored
 */
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);

String download_dir = request.getParameter("download_dir");
String DEF_FILE_TYPE = "Downloadable File";

//out.println(download_dir);

if (download_dir != null && !"".equals(download_dir)) {
    CmsObject cmso = cms.getCmsObject();
    try {
        // We have to use Cms* objects to get files that are not Pages.
        Iterator i = cmso.getFilesInFolder(download_dir).iterator();
        int lines = 0;
        while (i.hasNext()) {
            CmsFile f = (CmsFile)i.next();
            if(lines % 2 == 0) out.println("<tr
class=\"download-row1\">");
            else out.println("<tr class=\"download-row2\">");
            
            // There is probably a built-in source for this....
            HashMap fTypes = new HashMap(35);
            fTypes.put(".txt","Text File");
            fTypes.put(".doc","MS Word Doc");
            fTypes.put(".htm","Web (HTML) Document");
            fTypes.put(".html","Web (HTML) Document");
            fTypes.put(".jpg","JPEG Image File");
            fTypes.put(".jpeg","JPEG Image File");
            fTypes.put(".gif","GIF Image File");
            fTypes.put(".pdf","Adobe PDF (Acrobat™) Document");
            fTypes.put(".zip","ZIP Compressed File");
            fTypes.put(".tar","UNIX Archive File");
            fTypes.put(".tgz","GZip Compressed Archive File");
            fTypes.put(".gz","GZip Compressed File");
            fTypes.put(".gzip","GZip Compressed File");
            fTypes.put(".xls","MS Excel Spreadsheet");
            fTypes.put(".ppt","MS PowerPoint Slideshow");
            fTypes.put(".exe","Windows/DOS Executable");
            fTypes.put(".wmf","Windows Media File");
            fTypes.put(".ram","Real Media File");
            fTypes.put(".rpm","Real Media File");
            fTypes.put(".mp3","MP3 Audio File");
            fTypes.put(".mpg","MPEG Video File");
            fTypes.put(".mpeg","MPEG Video File");
            fTypes.put(".avi","AVI Video File");

            String fName = f.getName();
            String ext = f.getExtension();
            int fLength = f.getLength();
            String unit = "Kb";
            if(fLength < 1024) unit = "bytes";
            else fLength /= 1024;
            //out.println("Extension from CMS: "+ext+"<br>");//DEBUG

            String fileType;
            if("".equals(ext)) fileType = DEF_FILE_TYPE;
            else fileType = (fTypes.get(ext) !=
null)?fTypes.get(ext).toString():DEF_FILE_TYPE;

            out.println("<td class=\"download-cell\"><a href=\"" +
cms.link(f.getAbsolutePath()));
            out.println("\" class=\"download-link\">" + fName +
"</a></td>");
            out.println("<td class=\"download-cell\">" + fileType +
"</td>");
            out.print("<td class=\"download-cell\">");
            out.print(fLength);
            out.println(" "+unit+"</td>");
            ++lines;

        }
    } catch (Exception e) {
        out.println(e.toString());
    }
}

%>
</table>


On Fri, 2003-08-08 at 07:47, Prestel Marianne wrote:
> Hi M and Guillaume, Hi all,
> 
> I followed your exchange of ideas.
> I'm developing a jsp that displays all documents of a download-gallery
> (including links and files: *.pdf, *.doc, ...).
> 
> Can I get the navigation of a named folder (not the current folder)?
> 
> Thanks for any help.
> 
> Regards Marianne
>  
> 
> -----Ursprüngliche Nachricht-----
> Von: Apostoly Guillaume [mailto:ApostolyG at mail.europcar.com]
> Gesendet: Freitag, 25. Juli 2003 16:39
> An: opencms-dev at opencms.org
> Betreff: [opencms-dev] how to include a link content ??
> 
> 
> Hi all,
>  
> I've developed a peace of JSP that display all documents (to be shown in
> navigation from a directory) by using cms.include.
> This is basically the code.
>  
> com.opencms.flex.jsp.CmsJspNavElement rootNe
> while (rootI.hasNext())
>     {
>     rootNe = (com.opencms.flex.jsp.CmsJspNavElement)rootI.next();
>     cms.include(rootNe.getResourceName());
>     }
> 
> This works, but if i put in my folder a link to another document, instead
of
> a page, this doesn't work anymore.
> So how can I : 
> - test if the current "rootNe" is a link or a page ?
> - gain access to the linked page to include it ?
>  
> Thanks by advance for your help,
>  
> Regards,
>  
> Guillaume.
>  
> _______________________________________
> Guillaume APOSTOLY 
> Business-Analyst EIS-BSD 
> Tél: +33 (0)1.30.44.95.22 
> Fax: +33 (0)1.30.44.98.08 
> ApostolyG at mail.europcar.com <mailto:ApostolyG at mail.europcar.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
> _______________________________________________
> 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>
_______________________________________________
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