Removing <root> entry

76 views
Skip to first unread message

Jeff

unread,
Oct 18, 2010, 8:28:20 PM10/18/10
to dirhtml discussion group
I remember fighting a while back to remove the <root> text from a
dirhtml listing, I spent the better part of an hour pulling my hair
out trying it with the latest release, but can't seem to find it in
the code anywhere. I can remove '&lt;root&gt;' from the Root Anchor
Default words, but then I have an empty table row in the upper left of
the list, no text, but the empty box.
This is a screenshot of the <root> I am trying to get rid of.

http://i61.photobucket.com/albums/h44/trudy_w/Jeff_Storage/dirhtml.png

dirhtml

unread,
Oct 18, 2010, 10:30:50 PM10/18/10
to dirhtml discussion group
That's a good question.

At one time, clearing the root default word did suppress root anchor
link generation in the anchor table as well in the file table. It
also suppressed /ANCHOR and /ANCHOR_BEFORE and /ANCHOR_TD script
sections for the root anchor.

dirhtml

unread,
Oct 18, 2010, 11:01:21 PM10/18/10
to dirhtml discussion group
Well, I remember why I did it.

If you have a script with something like this:

/ANCHOR
%%FILEdescription.txt%</td></tr>
<tr class="noborder"><td colspan="%%COLUMNS%" style="background:
#a4997b; color: #595959">
<center>Files: %%ANCHOR_TOTAL_FILES%&nbsp;&nbsp;&nbsp;&nbsp;Size: %
%ANCHOR_TOTAL_SIZE%</center>

...and the root anchor is blank, the generated file will have an empty
<td><tr> which looks bad (very bad if there's a background color that
stands out).

I'm not sure of the best way to fix the problem at the moment.

dirhtml

unread,
Oct 18, 2010, 11:26:19 PM10/18/10
to dirhtml discussion group
In order for /ANCHOR to work the way it was originally intended, it
needs to be able to close out the current anchor <tr><td> and start a
new row. If a root anchor table row/cell is not generated, any script
that closes the anchor row/cell will break html validity. Not a good
result at all.

It's not acceptable for dirhtml to adjust script code in any way.

Here's a sample with no root showing in the anchor table and a bad
looking first row in the file table:
http://dirhtml.home.comcast.net/~dirhtml/no-root-anchor.html

Jeff

unread,
Oct 19, 2010, 8:10:58 PM10/19/10
to dirhtml discussion group

Would it be possible in the future for the script to use if/else
statements when clearing the default words to get around the td/tr
problem?

dirhtml

unread,
Oct 20, 2010, 10:31:01 AM10/20/10
to dirhtml discussion group
That solution would work, but it seems wildly complicated to
implement.

In the end, what I will probably do is test for an unmatched </td></
tr> in /ANCHOR sections for blank root anchors only. If it's present,
the table row won't be generated and the first </td></tr> will be
deleted from the script code (just for the root anchor). That would
mean that no scripts would need be changed and no new sections added.

Jeff

unread,
Oct 20, 2010, 9:32:26 PM10/20/10
to dirhtml discussion group
Sounds good, thanks!

dirhtml

unread,
Oct 24, 2010, 12:44:28 AM10/24/10
to dirhtml discussion group
Alpha 1 of dirhtml v4.855 is up and seems to be working:
http://dirhtml.home.comcast.net/~dirhtml/dirhtml_v4-855_ALPHA_1.zip

It's a good thing I had multiple levels of indirection in the sample
script. Otherwise, scripts that had something before the first </td></
tr> in an /ANCHOR section would have not worked properly under certain
conditions.

Here is a sample included file in a root folder ("description.txt").
It works with or without a root anchor being generated:
</td></tr>
<tr class="noborder"><td colspan="%%COLUMNS%" class="notes-color">This
is the root folder (blah, blah, blah)

And the script snippet that references the file (which works correctly
whether or not the "description.txt" file exists):
/ANCHOR
%%FILEdescription.txt%</td></tr>
<tr class="noborder"><td colspan="%%COLUMNS%" style="background:
#a4997b; color: #595959 text-align: center">

dirhtml

unread,
Oct 24, 2010, 1:00:55 AM10/24/10
to dirhtml discussion group
A working example, which no root anchors generated, and an included
file via an /ANCHOR section:

http://dirhtml.home.comcast.net/~dirhtml/no-root-anchor_(working).html

Incidentally, you can ignore the malformed URI references that some
validation engines complain about on that page. They are all for
filenames with chinese, cyrillic or greek characters.

dirhtml

unread,
Oct 24, 2010, 11:51:25 AM10/24/10
to dirhtml discussion group
On second thought, an opening </td></tr> does not belong in an
included file. It should always be in the script, where it can be
removed if needed.

So, the "description.txt" above should be:

Jeff

unread,
Oct 31, 2010, 3:37:00 PM10/31/10
to dirhtml discussion group
Downloaded A1 as linked above, it works the way I hoped, thank you.
Reply all
Reply to author
Forward
0 new messages