Permlink Replies: 6 - Pages: 1 - Last Post: 18-Jul-2004 16:10 Last Post By: Chane Threads: [ Previous | Next ]
davidekholm

Posts: 3,494
Registered: 18-Oct-2002
Links to sibling directories
Posted: 06-Jun-2004 23:36
  Click to reply to this thread Reply
Some users have asked for a link list of sibling/neighbour directories next to the thumbnails of a certain directory. Here is a small script that produces just this. Paste it inside the index.htt file of some skin.
<%
  // Make links to sibling directories
  File parentDir = imageDirectory.getParentFile();
  File[] files = engine.listFiles(parentDir, true, programDirectory);
  for (File f : files) {
    if (f.isDirectory()) {
      if (f.equals(imageDirectory))
        out.println("<b>" + f.getName() + "</b>");
      else out.println("<a target=\"_top\" href=\"../" +
       engine.encode(f.getName() + "/index.html") + "\">" + f.getName() + "</a>");
    }
  }
%>
thorstenzuerich

Posts: 2
Registered: 12-Jun-2004
Re: Links to sibling directories
Posted: 14-Jun-2004 10:54   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Thanks for the code. Works great.
What I didn't manage to do was to change the scirpt, that the labels of the folders (taken form the meta.properties file) is displayed, rather than the folder's acual name.
could you help me again? What should I write instead of f.getName().

thanks
davidekholm

Posts: 3,494
Registered: 18-Oct-2002
Re: Links to sibling directories
Posted: 14-Jun-2004 17:03   in response to: thorstenzuerich in response to: thorstenzuerich
  Click to reply to this thread Reply
Try adding this first (untested)
<%
  import se.datadosen.util.*;
  String getTitle(File dir) {
    File propsFile = new File(dir, "meta.properties");
    if (propsFile.exists()) {
      Properties props = IO.readPropertyFile(propsFile);
      String newTitle = props.get("title");
      if (newTitle != null) return newTitle;
    }
    return dir.getName();
  }
%>

Now you should be able to replace the f.getName() call with getTitle(f)
thorstenzuerich

Posts: 2
Registered: 12-Jun-2004
Re: Links to sibling directories
Posted: 16-Jun-2004 20:28   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Thanks again, works great. Now, I ran into the next problem. Could you help me again?
I have my album organized in several nested albums (3 levels). On all index and slide pages, I'd like to have a list of dicrectories based on the folders in the root (0 level). Would that be possible.
Thanks t.
davidekholm

Posts: 3,494
Registered: 18-Oct-2002
Re: Links to sibling directories
Posted: 18-Jun-2004 21:44   in response to: thorstenzuerich in response to: thorstenzuerich
  Click to reply to this thread Reply
Yes, replace imageDirectory.getParentFile() by rootImageDirectory
davidekholm

Posts: 3,494
Registered: 18-Oct-2002
Re: Links to sibling directories
Posted: 18-Jun-2004 21:46   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
And also replace the ../ construct with $rootPath
Chane
Re: Links to sibling directories
Posted: 18-Jul-2004 16:10   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
If you are using bluplusplus you can use this in index.htt to create a list of top level folders.

For example, if you have a folder structure like

top
2001
lots of subfolders and pictures
2002
lots of subfolders and pictures
2003
lots of subfolders and pictures
2004
lots of subfolders and pictures

Create a top level index.html customized for you contain links to 2001/index.html, ... 2004/index.html.

Invoke Jalbum 4 times building 2001, 2002, 2003, 2004.
This allows you to only build the folders that have changed (or in my case, since Jalbum would run out of memory before rebuilding all 25,000 pictures, invoke Jalbum on only a subset of pictures).

Add the code below right after the normal top navigation bar, before the graphics.

Now bluplusplus has 2 naviagation bars at the top.
The normal one and a new one list all of the sibling albums one level above your album.

<table class="topbar" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" nowrap>
<span class="bpppath">
 Jump To &bull; 
<%
  File myparentDir = rootImageDirectory.getParentFile();
  File[] files = engine.listFiles(myparentDir, true, programDirectory);
  for (File f : files) {
    if (f.isDirectory()) {
      if (f.equals(imageDirectory))
        out.println("<b>" + f.getName() + "</b> &bull;");
      else out.println("<a class=\"path\" target=\"_top\" href=\"../" + "$rootPath" + "/" + engine.encode(f.getName() + "/index.html") + "\">" + f.getName() + "</a> &bull;");
    }
  }
%>
 
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums