A Big Little Thing

It’s not unusual for people who maintain a website to want to create a hyperlink to another page on their site. The easiest way to accomplish this within TextStyleM would be to find the URL for the page to which the link should lead, complete with the request string (i.e., the bit of gibberish after the filename, like “?lang=1&menid=01&mtyp=3”). With the help of the built-in coding assistant, most TextStyleM users have come to master this technique after one or two tries.

But there was a problem with this “hard coded” approach. A big one!

It’s also not unusual for people to add new menus and submenus to their site, and that’s also quite easy to do in TextStyleM. However, when, on the one hand, someone added a page “between” two existing pages, and, on the other hand, someone had created a link earlier to the page that is now below the new page, that link he or she had created earlier would thereafter lead to the wrong page (namely, the new one). Follow me thus far?

To avoid this hassle, some users simply added new pages at the end of a submenu in order not to screw up any prior links they created. That meant that, over time, the sequencing of items in some submenus became counterintuitive from the perspective of readers. Yet I’m all about making the site friendly to the readers as well as easy for the publisher to maintain. Surely there had to be a way to refer to a page on the local site while abstracting its physical location, which could be changed at any time.

redirect.gifSo of course, necessity being the mother of invention, I came up with a solution tonight. From now on, when editors write or revise a text on their website, this “redirection” icon will appear in the coding assistant. Clicking on this icon will open a new browser window to view the site, except that it will also show a “stable” referrer for the page being viewed — a true “permalink” as we often encounter on blogs. Editors need only click their way to the page to which they want to link and copy-and-paste that referrer code to the page being edited (something like {L_LOCAL M12 A0 P0}{/L_LOCAL}). Even if the viewed page changes location later on, the hyperlink created by this referrer code will always lead to the intended page.

The crazy part? It took me hours of thought and planning, on and off, to come up with a way of accomplishing this feat and about 8 hours to write and tweak the function. The final tweaking will consist of making sure that if a menu or an article is permanently deleted, TextStyleM will scan the entire site and remove the links that are no longer going to work. That may sound outlandish, but TextStyleM already does that with other components, most notably images. Indeed, already if someone deletes an image, any reference to that image on the site gets deleted, meaning that readers of a TextStyleM-driven site never encounter one of those unsightly broken images. So, for the sake of consistency, I should apply the same “smartness” to this new function.