This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 10 - Pages: 1 - Last Post: 21-Sep-2018 21:25 Last Post By: jGromit Threads: [ Previous | Next ]
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Variable for the raw folder name
Posted: 11-Jun-2010 16:41
 
  Click to reply to this thread Reply
I've been trying to tighten up some of my variable handling, and have run into an odd situation. Maybe I'm just missing something....

If a user enters a Title for a folder, that becomes ${folderTitle}. The original, raw name of the folder is no longer readily available, because ${title} also picks up that entered Title. This is generally not a problem, since a skin would always want to use the entered Title for display purposes, anyway.

But it gets interesting if the user edits a folder, goes to the Title field, and just hits the space bar once or twice. Now both ${folderTitle} and ${title} are effectively empty, and are certainly empty if you do a .trim() on the variable. At that point, I'd like to grab the raw folder name, instead, but as far as I can tell, there's only one way to get to it, and that's to do some sort of messy string manipulation on ${imageDirectory}.

It would be really nice to have a ${folderName} variable that was always, reliably, just the raw folder name.
davidekholm

Posts: 3,545
Registered: 18-Oct-2002
Re: Variable for the raw folder name
Posted: 11-Jun-2010 17:04   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Wouldn't it be smarter if Jalbum instead ignored empty titles?
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 11-Jun-2010 17:08   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Yes, even better. I believe that's what the current albumTitle does - if you enter just spaces, it ignores you, and reverts to the raw image directory name. Do that for fileTitle and folderTitle, and I'm probably home-free!
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 29-Oct-2010 00:34   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Still a problem in Jalbum 8.12.
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: Variable for the raw folder name
Posted: 29-Oct-2010 17:37   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
EarlyOut wrote:

It would be really nice to have a ${folderName} variable that was always, reliably, just the raw folder name.


What about ${fileName} ?
If current file is a folder, this is effectively the reliable raw folder name, isn't it?
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 29-Oct-2010 17:46   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
There's a scope problem, there. Let's say I'm generating an index page. If I'm in an iterator loop, and looking at an item that's a folder, then yes, ${fileName} returns the raw name of the folder.

But what I'm trying to grab is the name of the current folder that contains all of these items, i.e., one level up. The {$title} variable returns that, but only if ${folderTitle} is empty. Outside of the iterator loop, ${fileName} is undefined.
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: Variable for the raw folder name
Posted: 29-Oct-2010 19:05   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Ah I see. Well, I have lots of dedicated variables for various cases, and I hardly make use of the $title fallback schemes.
I get the raw directory name like this:
String pageTitle = imageDirectory.getName();
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 29-Oct-2010 20:56   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
I agree - variables with fallbacks are more trouble than they're worth. I prefer dealing with variables that get defined as one thing, and reliably stay there. A coworker and I used to say, about software that tried to anticipate what we wanted, "Don't do me any favors!" ;)

Grabbing imageDirectory.getName() looks like a good solution - I'll switch to that in the next version of Matrix. It's needed both for the title bar area, where there's an option to show the folder title/name, and in the breadcrumb trail.

Thanks!
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 29-Oct-2010 22:06   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Though my immediate problem is solved, I'll leave this thread "unanswered," because I still think it would be a very good idea if the user interface ignored the entry of a fileTitle or folderTitle that was all spaces, just as it currently ignores an albumTitle that's all spaces.
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: Variable for the raw folder name
Posted: 31-Oct-2010 12:05   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
EarlyOut wrote:
I still think it would be a very good idea if the user interface ignored the entry of a fileTitle or folderTitle that was all spaces, just as it currently ignores an albumTitle that's all spaces.

Agreed.

Furthermore, to be on the safe side and to not clutter my generated HTML code with blank <DIV>s, I do a test for "empty" text variables on all CA2 user variables:
//
// Returns true if an empty string
//
 
public boolean isEmptyString(Object obj) {
	return ( obj==null || obj.toString().trim().equals("") );
}
jGromit

Posts: 7,270
Registered: 31-Jan-2006
Re: Variable for the raw folder name
Posted: 21-Sep-2018 21:25   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
Though my immediate problem is solved, I'll leave this thread "unanswered" ....

Just going through the list of "stuff that's still hanging around...."

This started as a feature request, but I think it's more of a bug. It should now be classified as jAlbum archaeology, and is still present. If you enter just spaces for the album title or description, jAlbum ignores the entry, as it should. But the folder title and description/comment don't behave the same way. And really, the file title and comment should do the same - if it trim()'s to an empty string, don't save it.
Legend
Forum admins
Helpful Answer
Correct Answer

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