Using route_short_name for html output

17 views
Skip to first unread message

LT

unread,
Aug 25, 2011, 11:59:06 AM8/25/11
to ttpub-user
Hello, once again! I've had much success customizing the templates to
our needs. However, I've been stumped trying to figure out how to get
constants.ftl to assign the routeURL to route_short_name rather than
route_id (using routes.txt, I'm assuming.) I'm not a coder by any
stretch of the imagination, but rather a designer, so much of what
I've done has been guesswork and trial/error. What code is telling
ttpub which column to use for the naming of the routeURL, and how do I
modify it to choose a different column? Thanks so much for your help!

Frank Purcell

unread,
Aug 25, 2011, 5:56:33 PM8/25/11
to ttpub...@googlegroups.com
Hey Lonnie,

Glad to hear you're having some success.  Try adding the following to the bottom of constants.ftl:

[#assign routeUrl = "../r" + timesTable.getRouteShortName()?default("undefined")?left_pad(3, "0")  + ".htm"]


Just to break down what's happening in the line above:
     "../r"                            : at TriMet, we have route landing pages that live in the parent directory of the timetables, ala http://trimet.org/schedules/r004.htm

     ".htm"                         : each route landing page begins with an 'r' and ends in '.htm', and is then made of the 3 character route id (and where the route id has less then 3 characters, it's padded with zeros)

     timesTable                  : timesTable is a controller object that contains all the route and schedule information

     .getRouteShortName() : is a method of timesTable that is used to retrieve the route_short_name data for this route

     ?default("undefined")    : if .getRouteShortName() returns an empty string for some reason, use 'undefined' as a default value ... good here, since it won't make the page blow up with errors early if there's no short-name available

     ?left_pad(3, "0")          : for strings that are shorter than 3 characters in length, pad the string with "0" until it is 3 characters long -- makes sense for TriMet, since we wanted 004 to point to the line 4's timetable, etc...

If you don't need any of the defaults or padding, feel free to remove, etc...   And the lines following the routeNum assignment are those that appear on the timetable for things like the pdf, etc...  More customization can


Take care,
Frank


LT

unread,
Aug 26, 2011, 5:13:35 PM8/26/11
to ttpub-user
Excellent. All of that makes sense. Thanks for the explanation!

On Aug 25, 3:56 pm, Frank Purcell <fxpurc...@gmail.com> wrote:
> Hey Lonnie,
>
> Glad to hear you're having some success.  Try adding the following to the
> bottom of constants.ftl:
>
> [#assign routeUrl = "../r"
> + timesTable.getRouteShortName()?default("undefined")?left_pad(3, "0")  +
> ".htm"]
>
> Just to break down what's happening in the line above:
>      "../r"                            : at TriMet, we have route landing
> pages that live in the parent directory of the timetables, alahttp://trimet.org/schedules/r004.htm
Reply all
Reply to author
Forward
0 new messages