space Baylys
Just practicing to pass the Turing test.
space
space
space
space
Developer for Hire!
space
addedValues Plugin
space

Home

What's new

Bayly.Root

Cornershop Plugin

Career

edutools Root

Enhancements

Interests

linguist Plugin

Manila

space

Custom Prefs required Items

Frames in Manila

How to implement Scalable Content

Manila Custody Issues

Manila Minor Bugs, Gotcha's and Workarounds

Plug-ins

Plugin Visibility

Static Rendering Howto

Techniques

space
space

Path Attributes

Site Specific Callbacks

Site specific macros

space

URL Encoding in Manila

Patches

Patches by Group

Papers

Sales

Sign My Guestbook

User(land) Relations.

Contact Address

Search Baylys

urlchains

space
Join Now
Login
space space space

Site Structure Path Attributes

If you are a Frontier old timer, you may recall directives in Frontier websites. They are a way of assigning values to arbitrarily named entities on a page by page basis. The values can be used in macros and were the basis of a lot of neat features. You could set the values by placing a line in your comment wpText or outline preceded by a # character.

In Manila, directives still exist, but are part of the plumbing. You cannot add a story with a directive - it gets stripped out. There are good design reasons for that, but the loss of functionality is irksome. This post is how I found a way to restore something like directives to my Manila website. It uses some macros, but does not change any Userland code. For clarity I will call them path attributes.

A Manila site can have a site structure. Think of a site structure a rule to build a URL to get to a page. There is a HowTo about site structure hierarchy on the Manila site, so I won't try to explain the feature here. To use my technique you must have a site structure that contains a story entry for every page that needs a path attribute. Here is a simple page structure for myFirstSite. You can generate your own version of this and follow along

<hierarchy>
  <story name="FAQ" pathname="faq" msgNum="3"/>
  <story name="Feedback" pathname="feedback" msgNum="2"/>
  </hierarchy>

You can look at and edit, using Pike if you want, from the editors only/prefs/advanced page in your site. Suppose we do that and add a path attribute called choice to the two stories.

<hierarchy>
  <story name="FAQ" pathname="faq" msgNum="3" choice = "red"/>
  <story name="Feedback" pathname="feedback" msgNum="2" choice= "green"/>
  </hierarchy>

Manila will accept this but will not do anything with, it knows nothing of choice. So how do you make use of the value? Simple, use a macro. Let's assume the existence of a macro called manilaExtras.pathAtt which takes the name of desired attribute and returns the value for this page. (You can get this and other macros mentioned here as explained below ) If the path attribute isn't defined it returns an empty string. Now we can get at the value of choice by inserting {manilaextras.pathAtt("choice")} in a story - or in the template. Let's put it in the template.

<html>
  <head><title>{title}</title>
  {meta}
  {cascadingStyleSheet}
  {javaScript}
  </head>
  {body}
    <center>
      <table cellspacing="0" cellpadding="0" border="0">
        <tr>
          <td colspan="5">
            {editorialMenu}<p>
            <font size="+3"><b><a href="http://homebase.dab.net/MyFirstSite/";>{siteName}</a></b></font><br>
            <i>{tagLine}</i>
            </td>
          </tr>
        <tr height="25"><td colspan="3"> </td></tr>
        <tr>
          <td valign="top" align="right">{navigatorLinks}<p><br><br>{membershipBox}</td>
          <td width="10"> </td>
          <td width="1" bgcolor="gray">{spacePixels ("1")}</td>
          <td width="10"> </td>
          \<td valign="top" width="600" bgcolor = "{manilaextras.pathAtt(\"choice")}">
            <h2>{title}</h2>
            {bodytext}
            <p>
            </td>
          </tr>
        <tr>
          <td colspan="5">
            <br><br><hr size="1" noshade>Last update: {lastUpdateString}.
            </td>
          </tr>
        </table>
      </center>
    </body>
  </html>

You'll have to make manilaextras a legal macro to do this, which means you must have access to your server. Notice the escape of the < which allows macro evaluations to take place within the td tag. Now go to /myfirstsite/faq. What colour is the background?

Getting access to values is nice, but directives had a further interesting property. They were inherited. Set a value once in a table corresponding to a folder of web pages and all pages and pages within contained folders also had that value. Path Attributes can work that way too - it all depends on the macro. Here's an example

<hierarchy>
  <category name="English" pathname="en" flag = "UK.gif">
    <story name="FAQ" pathname="faq" msgNum="3"/>
    <story name="Feedback" pathname="feedback" msgNum="2"/>
    </category>
  <category name="Deutsch" pathname="de" flag = "Germany.gif">
    <story name="FAQ" pathname="faq" msgNum="12"/>
    <story name="Feedback" pathname="feedback" msgNum="14"/>
    </category>
  <category name="Francais" pathname="fr" flag = "France.gif">
    <story name="FAQ" pathname="faq" msgNum="13"/>
    <story name="Feedback" pathname="feedback" msgNum="15"/>
    </category>
  </hierarchy>

The way that pathAtt works, is that it looks up through the hierarchy. So if the page is at url fr/feedback, pathAtt has to back up to fr to find the value "France.gif". This resembles the inheritance properties of directives.

Returning strings can be useful, but another useful macro gets the value and then looks for a picture shortcut with that name. if it finds it, it returns a url. It takes an optional second parameter which is the name of a binary in the #image table. Manila always put a space gif in there, so that is the default. So change our example a little

<hierarchy>
  <category name="English" pathname="en" flag = "UK Flag">
    <story name="FAQ" pathname="faq" msgNum="3"/>
    <story name="Feedback" pathname="feedback" msgNum="2"/>
    </category>
  <category name="Deutsch" pathname="de" flag = "Germany Flag">
    <story name="FAQ" pathname="faq" msgNum="12"/>
    <story name="Feedback" pathname="feedback" msgNum="14"/>
    </category>
  <category name="Francais" pathname="fr" flag = "France Flag">
    <story name="FAQ" pathname="faq" msgNum="13"/>
    <story name="Feedback" pathname="feedback" msgNum="15"/>
    </category>
  </hierarchy>

and upload pictures called UK Flag, etc to manila and you can then arrange to see the appropriate picture by adding something like

\<img src = '{manilaextras. pathPictureURL("flag")}'>

to the template. Voila, page specific flag on every page.

Finally. The last trick, which can be seen in action at <http://www.quint-essenz.ch:8080/> is menus that adapt to the location of the current page within the site. This is (loosely) based on a suite from Seth Dillingham, called SiteLiner. This is a lot more complicated to explain so I will wait to see if there are any requests to do so.

If you want to play with this technique, download my public domain guest database. It contains a table called Manilaextras with these macros.

Unfortunately Radio Userland does not preserve path Attributes when updating site structure, so it is better to avoid updating the site structure with Radio Userland if you use Path Attributes.