> I'm trying to make a link out of the day.  I have certain daily
> functions I perform, and their procedures are listed under a wiki of
> the day [[Monday]] etc.  Well I recently learned about macros <<today
> DDD>> does pull up the name of the day, but I cant seem to make it
> into a link in any conventional way.  Anyone?

Unfortunately, because of the way macros work in TW, it's not possible
to combine the "output from a macro" with some surrounding syntax and
then have that combination parsed as if it had been entered as text.

For example, using a macro inside the PrettyLink syntax, like this:
   [[text to show|<<today>>]]
is *not* valid TW syntax.

The reason is that when a macro is invoked by the TW core's "wikify()"
engine, it doesn't generate *text* that is inserted into the source
and then parsed to produce the final rendered result.  Rather, each
macro is responsible for rendering it's own output (if any) by
directly generating browser DOM elements into a containing 'place'
that is passed to the macro by the core engine.

Fortunately, there *are* several ways to create dynamically-assembled
output, depending upon your specific needs.  One method uses only TW-
native syntax by combining 'hidden sections' and 'transclusion with
evaluated parameters'.  For example, you can put the following in a
tiddler named [[LinkToToday]]:
   /%
   !show
   [[$1]]
   !end
   %/<<tiddler LinkToToday##show
      with: {{new Date().formatString('DDD');}}>>
you can then embed this output into another tiddler's content, like
this:
   <<tiddler LinkToToday>>

Alternatively, you can use this plugin:
   http://www.TiddlyTools.com/#WikifyPlugin
to do something very similar, with a more compact syntax:
   <<wikify "[[%0]]" {{new Date().formatString('DDD');}}>>

You could also use this plugin:
   http://www.TiddlyTools.com/#DatePlugin
which provides a variety of enhanced date display, link and advanced
popup features, allowing you to write:
   <<date link today DDD>>
to create the desired link.

...and, if that's not sufficient, with this plugin:
   http://www.TiddlyTools.com/#InlineJavascriptPlugin
you can use almost any javascript-programmed logic you want to
generate dynamic output, like this:
<script>
   var day=new Date().formatString('DDD');
   if (['Saturday','Sunday'].contains(day))
      return "It's the weekend... go out and play!";
   else
      return "[["+day+"]]";
</script>

However... based on this further bit of info from you:
   "To add today's Tiddler to the DefaultTiddler"
it would seem that none of the above is quite the right fit, because
what you want to do is alter the content of [[DefaultTiddlers]] so
that it affects *startup processing*.

Unfortunately,  the previously described techniques are all used to
generate linked date output *within a rendered tiddler*, which occurs
long after startup processing has been completed.

Fortunately, there is still a relatively easy way to do what you
want...

1) Start by creating a tiddler (give it a name like
[[SetDefaultTiddlersPlugin]])
2) Enter the following javascript code:

//{{{
var now="[["+new Date().formatString('DDD')+"]]";
config.shadowTiddlers['DefaultTiddlers']=now;
//}}}

3) Add the 'systemConfig' tag (to indicate that this is a plugin)
4) Press 'done'
5) Delete (or rename) any existing [[DefaultTiddlers]] (so that the
shadow tiddler will be applied the next time the document is opened)

When the document is saved-and-reloaded, the tiny plugin you just
created will be invoked during startup, and the DefaultTiddlers shadow
content will be updated with a link to the current day name.  Then,
when the DefaultTiddlers definition is *applied* (near the end of the
startup process), the desired day-named tiddler  (e.g., "[[Monday]]",
"[[Tuesday]]", etc) will be automatically opened, based on the content
your plugin has written into the shadow tiddler.

QED.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to