This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 7 - Pages: 1 - Last Post: 19-Oct-2015 11:06 Last Post By: Laza
AndreWolff

Posts: 2,144
Registered: 14-Dec-2007
File navigation-bar.inc is missing
Posted: 09-Oct-2015 13:30
 
  Click to reply to this thread Reply
I was looking for a good example skin to create the folders menu, so I did investigate the Base skin.

In file tweaking.txt is stated:

“The structure of a skin ….
  • navigation-bar.inc (the code that compiles the navigation bar if the album is used as a site)”

But I can't find that file in the Base skin directory.

So my question is:

Where can I find a good description how to code the folders navigation bar?
Laza

Posts: 9,471
Registered: 6-Sep-2005
Re: File navigation-bar.inc is missing
Posted: 14-Oct-2015 19:39   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Yes, true, the navigation has been moved into the page-header.inc. The ${topNavigation} variable is then created by the help of the Util.java. Here's the method:
	// Get the whole navigation menu
 
	public String getNavigation(AlbumObject co) {
		return getNavigation(rootFolder, co, "", 3, true, false);
	}
 
	public String getNavigation(AlbumObject co, boolean home) {
		return getNavigation(rootFolder, co, "", 3, home, false);
	}
 
	public String getNavigation(AlbumObject co, boolean home, boolean excludeFolders) {
		return getNavigation(rootFolder, co, "", 3, home, excludeFolders);
	}
 
	public String getNavigation(AlbumObject co, int depth) {
		return getNavigation(rootFolder, co, "", depth, true, false);
	}
 
	public String getNavigation(AlbumObject folder, AlbumObject co, String relPath, int depth, boolean home, boolean excludeFolders) {
		StringBuilder sb = new StringBuilder(2048);
		boolean isFolder;
		Category cat;
		String t, root = getRootPath();
		String path, relp = (relPath.length() == 0)? "" : (relPath + "/");
		Scope vars;
 
		if ( home ) {
			sb.append("<li class="\"controls" home\"><a href=\"").append(root).append(indexName).append("\" title=\"").append(getText("home")).append("\"> </a></li>");
		}
		for (AlbumObject ao : folder.getChildren()) {
			if (ao.isIncluded()) {
				
				cat = ao.getCategory();
				isFolder = cat == Category.folder;
				
				if ((cat == Category.webPage) || (!excludeFolders && isFolder && !ao.isHidden())) {
					vars = ao.getVars();
					path = (String)vars.get("closeupPath");
					if ( path != null && !indexName.equals(path) ) {
						t = (String)vars.get("title");
						if (cat == Category.webPage && t.equals("NewPhotos"))
							t = getText("newPhotos");
						sb.append("<li").append((co.isWithin(ao))? " class=\"actual\"" : "").append(">");
						sb.append("<a href=\"").append(root).append(relp).append(path).append("\">").append(t).append("</a>");				
						if ( isFolder && depth > 0 )
							sb.append(getNavigation(ao, co, relp + path.substring(0, path.length() - indexName.length() - 1), depth - 1, false, false));
						sb.append("</li>");
					}
				}
			}
		}
 
		if (sb.length() > 0) {
			sb.insert(0, "<ul>");
			sb.append("</ul>");
		}
 
		return sb.toString();
	}
AndreWolff

Posts: 2,144
Registered: 14-Dec-2007
Re: File navigation-bar.inc is missing
Posted: 15-Oct-2015 17:46   in response to: Laza in response to: Laza
 
  Click to reply to this thread Reply
Attachment init.bsh (7,6 KB)
Laza wrote:
Yes, true, the navigation has been moved into the page-header.inc. The ${topNavigation} variable is then created by the help of the Util.java.
Thanks Laza for sharing this code.

I see that the Base skin uses a module Util.jar, but I can't find more information about this module, I did find only Package se.datadosen.util, but that does not contain the methods you indicate.

I did a test to see whether I could use your code.

If add this code to my init.bsh file:
import se.datadosen.util.*;
 
// Util library
Util util = new Util(engine);
engine.setUsing(util);
 
// Navigation bars - the variables used on the page
String topNavigation;
 
void initPage() {
		// Navigation links for the index page
		topNavigation = util.getNavigation(currentObject, level > 0);
}

I get a first fairly good result see this album.
You should compare this with the result of the current Slide Show 4 skin.

I can't use your code unchanged, because the music web-page has to be opened in a new window as in the current version of the Slide Show 4 skin.

So I tried to change your code, by copying the code you did give above to my init.bsh module.

However in that case I get a compiler error:
 Token Parsing Error: Lexical error at line 45, column 47.  
 Encountered: "\\" (92), after : "" : at Line: 32

Line 45 contains your next code:
32	public String getNavigation(AlbumObject co, int depth) {
		return getNavigation(rootFolder, co, "", depth, true, false);
	}
 
36	public String getNavigation(AlbumObject folder, AlbumObject co, String relPath, int depth, boolean home, boolean excludeFolders) {
		StringBuilder sb = new StringBuilder(2048);
		boolean isFolder;
		Category cat;
		String t, root = getRootPath();
		String path, relp = (relPath.length() == 0)? "" : (relPath + "/");
		Scope vars;
 
		if ( home ) {
45			sb.append("<li class="\" controls" home\"><a href=\"").append(root).append(indexName).append("\" title=\"").append(getText("home")).append("\"> </a></li>");		}

See also enclosed.bsh file.

So my questions are:

Any idea why this is not accepted?
Is this a public module which I can use to for my skin?
Where can I find a description of its methods and properties?

Edited by: AndreWolff on 15-Oct-2015 20:23
Laza

Posts: 9,471
Registered: 6-Sep-2005
Re: File navigation-bar.inc is missing
Posted: 15-Oct-2015 22:41   in response to: AndreWolff in response to: AndreWolff
Helpful
  Click to reply to this thread Reply
That's because of the forum motor. I can't fix it - it's stubborn - whenever it sees a class=something it adds quote marks around it. If you can look into the original code I posted (Edit), you'll see the difference:
sb.append("<li class=\"controls home\"><a href=\"")
AndreWolff

Posts: 2,144
Registered: 14-Dec-2007
Re: File navigation-bar.inc is missing
Posted: 15-Oct-2015 23:55   in response to: Laza in response to: Laza
 
  Click to reply to this thread Reply
Laza wrote:
That's because of the forum motor. I can't fix it - it's stubborn - whenever it sees a class=something it adds quote marks around it.
Yes, I did solve that, thanks for your help.

I do get now other error messages:

Command not found: getRootPath() : at Line: 40 which is:
String t, root = getRootPath();
Which module should I import to solve this?

and

Attempt to resolve method: equals() on undefined variable or class name: indexName : at Line: 56, which is:
if ( path != null && !indexName.equals(path) ) {
Laza

Posts: 9,471
Registered: 6-Sep-2005
Re: File navigation-bar.inc is missing
Posted: 16-Oct-2015 08:29   in response to: AndreWolff in response to: AndreWolff
Helpful
  Click to reply to this thread Reply
Attachment Util.zip (3,0 MB)
I think it's easier to give you the whole project. If you don't use NetBeans you can still compile Util.java in the src folder, just make sure jAlbum.jar is imported.
AndreWolff

Posts: 2,144
Registered: 14-Dec-2007
Re: File navigation-bar.inc is missing
Posted: 16-Oct-2015 09:52   in response to: Laza in response to: Laza
 
  Click to reply to this thread Reply
B> Laza wrote:
I think it's easier to give you the whole project. If you don't use NetBeans you can still compile Util.java in the src folder, just make sure jAlbum.jar is imported.
Thanks Laza, that module contains a lot of useful functions!

I could solve the reported problems by adding:
	public String pageExt = engine.getPageExtension();
	public String indexPageName = engine.getIndexPageName();
	public String indexName = indexPageName + pageExt;
	
43	public String getRootPath() {
44		String rp = (String)get("rootPath");
		
		if ( rp.equals(".") )
			rp = "";
		else
			rp += "/";
		
		return rp;
	}
But I got next error:
Typed variable declaration : Command not found: get( java.lang.String ) : at Line: 44

even if I import all the modules indicated at the start of your util module.

I could solve this by changing line 44 into:
String rp = rootPath;


And now I have it working with un-compiled code, see my France album.

One final question:
what is the meaning of
boolean home?

Thanks again for patience to help me!

Edited by: AndreWolff on 16-Oct-2015 12:16
Laza

Posts: 9,471
Registered: 6-Sep-2005
Re: File navigation-bar.inc is missing
Posted: 19-Oct-2015 11:06   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
That's just an option to use the HOME link in the top bar. It will add a link in this format:
<li class="controls home"><a href="../index.html"> </a></li>
Legend
Forum admins
Helpful Answer
Correct Answer

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