How access tiddler content using macro

36 views
Skip to first unread message

Larys

unread,
Jul 2, 2011, 4:01:16 PM7/2/11
to TiddlyWiki
Hi,

I'm a bit new to writing macros/plugins and though I have taken a
javascript class, I'm still not sure how to access a specific
tiddler's content.

My goal: Make a macro that takes the text from the tiddler siteTitle
and displays it when you write <<siteTitle>> anywhere on the site --
same with siteSubtitle, respectively.

I read the tutorial on how to create a custom macro here:
http://oldwiki.tiddlywiki.org/wiki/Dev:Custom_Macros
but I still don't know how to access the specific tiddlers "siteTitle"
and "siteSubtitle"

Could anyone give me any pointers, please? Any help would be much
appreciated.

Cheers!
Larys

Eric Shulman

unread,
Jul 2, 2011, 5:10:56 PM7/2/11
to TiddlyWiki
> My goal: Make a macro that takes the text from the tiddler siteTitle
> and displays it when you write <<siteTitle>> anywhere on the site --
> same with siteSubtitle, respectively.

As an exercise in macro writing, I suppose those would be as good as
any.

However, the functionality you describe is already provided by TWCore
macro:
<<tiddler TiddlerName>
will 'transclude' (aka, embed) content from the named tiddler into the
current one.

> I read the tutorial on how to create a custom macro here:http://oldwiki.tiddlywiki.org/wiki/Dev:Custom_Macros
> but I still don't know how to access the specific tiddlers "siteTitle"
> and "siteSubtitle"

var txt=store.getTiddlerText("NameOfTiddler","default value");

If the named tiddler doesn't exist, it returns the indicated default
value (or NULL if no default is provided)

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Help support TiddlyTools:
http://www.TiddlyTools.com/#Donate (paypal)
TiddlyWiki Professional Consulting:
http://www.TiddlyTools.com/#ELSDesignStudios
http://www.TiddlyTools.com/#Contact

Larys

unread,
Jul 2, 2011, 7:03:15 PM7/2/11
to tiddl...@googlegroups.com
Eric Shulman,

Thank you so much! It works perfectly and just as I needed. I have tried to create plugins and macros but not with much luck, generally. I can do web pages fine on my own but often come into problems when extending others' code...I get easily lost in their work, unfortunately. I do wish there were a Tiddlywiki complete documentation/manual of some sort.

Anyway, thank you again! And another thank you for the amazing plugins you've created over the years! --I've been happily using them for a long time! :)

Cheers!
Larys

colmjude

unread,
Jul 4, 2011, 3:32:57 AM7/4/11
to tiddl...@googlegroups.com


Could anyone give me any pointers, please? Any help would be much
appreciated.

Here are a couple of resources you may find useful for your plugin writing escapades:

Hope that helps,

Colm
Reply all
Reply to author
Forward
0 new messages