Tip Three: Towards the "perfect" view
Since I first learnt about the base tag's href attribute I have used it in every single database I've written. If you don't already, I suggest you start. It saves endless amounts of time and code!
If you have views treated as HTML you will need create the links yourself. I've seen people do this and include the following code as part of a column's formula:
@ReplaceSubstring( @Subset( @DBName; -1); "\\"; "/");
Who knows what damage this can cause in a database when you move folders. Not to mention the impact on indexing performance. Well, when you use the base href method, you don't need the database's path as part of the link. Just the view name, as below:
Alternatively, you could always just start the link with the "0" view name, like below:
But sometimes there's a reason to use the actual view name in the link. To avoid hard-coding the view name in the links you can use the @ViewTitle, like below:
Notice we used @Subset to always get the last element in the view's list of names, which will be the alias that we want and not its full name. If there's only one name and no alias it will simply return this name.
You could argue this is just as much a drain on the indexer as the @DBName method. Maybe so, it's just something I've started doing more and more thought it worth passing on. If nothing else, you might have learnt a trick to find the alias of a view ;o)
Which reminds me; Februaury's article is going to be called something like "Towards the perfect view". Laurens Lochtenberg of Iqinfo is working on it as we speak.
Jake.
You still need to convert any spaces in your view title (if you use them) to %20 otherwise your links will not work in some browsers e.g Firebird
I still prefer to use base tag just for the leaner HTML page.
Err and one slight spelling mistake for the word February.
John Z
What do you mean? Aint' that how you say Februauaury ;o)
I always assume that, if there's an alias for a view, it won't contain a space anyway. I tend to name views with spaces and then make sure there's always an alias and that it's "web safe".
Jake,
What do you mean by "web safe" view aliases?
Wayne,
Presumable a web safe alias is one without any spaces in.
Wayne. Please see Nick after school.
I thought you said you were updating to ND6, Jake. Take a look at @WebDBName.
I am Stan. And I do use @WebDBName. The reason I didn't in this example is that I was merely talking about what I've seen other people code in their columns.
I just don't like @WebDBName personally. It doesn't allow you to step backwards through your URI - unless I'm missing something there's not a way to define a specific database's 401 page once you've "left" the database in question. I'll explain:
Let's say you're running two web apps, http_://_domain/dir1/appA.nsf and http_://_domain/dir2/appB.nsf. Sure, you can write a custom "You clicked on a bad link" for each of these apps using special forms etc, but if you hit http_://_domain/dir1 or /dir2 directly you get back crap.
At least if you're using the replicaID, you can step back from http_://_domain/repID back to the http_://_domain and not run into any problems (using subdomains for your apps/sites/whatever etc. understood).
-Chris