Frontier Tutorials / Indexing a Website / Display The Alphabetical Directory

Display The Alphabetical Directory

fatpage picture space picture This page is a Fat Page. It includes the TitleAlphaDirectory script, encoded by and for Frontier. To retrieve the script(s), save the page as source text and open it using the File->Open command.

As with the keyword index, to get the information out of the alphabetical index and onto a page, we need to create a macro.

We could format the directory a number of ways. For now, we'll make it look like this:

AAdd Keywords
BBricks and Mortar
Build the Alphabetical Index
Build The Keyword Index
DDisplay The Alphabetical Directory
Display The Keyword Directory
Downloadable Scripts
HHints and Tips
IIndexing a Website
PPlan the Project
SSummary

The TitleAlphaDirectory Macro

So let's create the TitleAlphaDirectory macro in the #tools table. We'll start by copying the TopicsDirectory macro we created earlier, then modify it to get the display we want.

Copy the TopicsDirectory Macro

Copy the TopicsDirectory macro, and rename it the copy "TitleAlphaDirectory". Don't forget to change the name of the eponymous script, as well.

Create a page named "Articles" at the top level of your website, with the following content:

#title "Articles Index"
{TitleAlphaDirectory(@indices^.titleAlpha,"ALL")}

Render the "Articles" page. You should get a hierarchical display of ODB addresses; it will resemble the following (yours will, of course, have your own keywords and page links in it, not mine):

A
Add Keywords
B
Bricks and Mortar
Build the Alphabetical Index
Build The Keyword Index
D
Display The Alphabetical Directory
Display The Keyword Directory
Downloadable Scripts
H
Hints and Tips
I
Indexing a Website
P
Plan the Project
S
Summary

We haven't even done anything yet, and it's already usable! But it's not quite what we want.

Modify The Script

Now we will modify the TitleAlphaDirectory macro to use tables instead of <blockquote> to create the display.

We'll use a two-column table, with the left column containing the single-character heading and the right column containing a set of linked page titles separated by <br> tags.

Start of Block

Each time we enter a new index subtable (corresponding to a new letter), we need to open a new table row and add a cell containing the letter, formatted as a heading. Then we will open a new cell to contain the individual items that fall under the specific letter.

Open up the TitleAlphaDirectory macro. Double-click the first summit to collapse it, then double-click again to expand it one level.

Expand the line that begins "on VisitCBFuncExt".

Expand the line that reads "case visitPhase", then the line that reads "cat_start".

Locate the lines that read:

Add( nameOf( itemAdr^ ) )
Add( "<blockquote>\r" )

Replace them with:

if ( outStr == "" )
space pictureAdd( "\r<table cellpadding=6 cellspacing=0 border=0>\r" )
Add( "<tr valign=top>\r" )
Add( "<th><font face='sans-serif' size=+2 color='#003366'>" + string.upper( nameOf( itemAdr^ ) ) + "</font></th>" )
Add( "<td>" )

Notice that this fragment also adds the opening <table> tag if outStr is empty.

End of Block

We need to close the current table cell and table row when we exit an index subtable.

Collapse the line that reads "cat_start", and expand the line that reads "cat_end".

Locate the line that reads:

Add( "</blockquote>\r" )

Replace it with:

Add( "</td></tr>\r" )

Individual Item

For each individual item, we need the title, linked to the actual page, followed by a <br> tag.

The AddOneItem nested script does this already, so we don't need to make any changes there.

Finish

We have to close the table.

Collapse the line that reads "cat_end", and expand the line that reads "finish".

Locate the comment line that reads:

<< No processing needed in this case, because the "cat_end" case closed the last blockquote.

Replace it with:

Add( "</table>\r" )

Render the "Articles" page again. You should now see an alphabetical display of page titles, with each title linked to the corresponding page:

AAdd Keywords
BBricks and Mortar
Build the Alphabetical Index
Build The Keyword Index
DDisplay The Alphabetical Directory
Display The Keyword Directory
Downloadable Scripts
HHints and Tips
IIndexing a Website
PPlan the Project
SSummary

Not Compact Enough?

Want to list the titles horizontally to make it more compact? Change the HTML generation to string the linked titles together:

AAdd Keywords
BBricks and Mortar - Build the Alphabetical Index - Build The Keyword Index
DDisplay The Alphabetical Directory - Display The Keyword Directory - Downloadable Scripts
HHints and Tips
IIndexing a Website
PPlan the Project
SSummary

To accomplish this, I changed "<br>" to " - " in AddOneItem() and trimmed the final " - " from outStr in the cat_end block.

Now let's review what we've covered.

Tutorial Contents
Indexing a Website
Bricks and Mortar
Plan the Project
Add Keywords
Build The Keyword Index
Display The Keyword Directory
Build the Alphabetical Index
Display The Alphabetical Directory
Summary
Hints and Tips
Downloadable Scripts
About the Author