How to add a custom view template to include Twitter macro from field?

I wrote up a bit of my workflow for my notes / personal CRM from @Mohammad’s prompt:

My question is, I fill out Tiddlers representing people by tagging with “Person” and then optionally including a Twitter field that includes a full link https://twitter.com/bmann.

How would I then have a custom view template for “Person” tiddlers, where after the body, a Twitter macro is included that automatically shows the last 3 tweets if the twitter field is filled out?

2 Likes

Here are some hints I’ve found that may help :

You can use an iframe to execute javascript code in a tiddler, here’s the code that twitter suggest for embedding an user timeline:

<iframe width="100%" srcdoc="""
<a class="twitter-timeline" data-dnt="true" href="https://twitter.com/jermolene">Tweets by Jermolene</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
"""
/>

Another, probably better option is to make a javascript macro.

There is this javascript library that can make API call to twitter and fetch content : https://github.com/remy/twitterlib/blob/master/README.markdown

I do not have the time right now to find a solution but I hope this will help !

2 Likes

Thanks! I was thinking the core #twitter-plugin could be used for this, which would remain robust and supported.

So, parsing the username out of the field and then inputting it into the right place of the macro.

Also: I’ll commit to documenting this but basically I’m at “explain it to me like I’m 5” (ELI5): how does one do a custom view template for only Tiddlers tagged with “Person”?

You, mean something like

<$list filter="[all[current]tag[People]]">
<<mytwittermacro ...>>
</$list>

Which is contained in tiddler tagged $:/tags/ViewTemplate ?

1 Like

There’s a core Twitter plugin so I assume that rather than “my” macro one can take the output of the field and enter it into the core macro?

(This use the core macro is the part that seems trickiest to me)

And to make sure I’m understanding, I can call the Tiddler Twitter Person Display, tag it with $:/tags/ViewTemplate, and your filter will make it only apply to ‘Person’ tagged Tiddlers, yes?

I haven’t used the Twitter widget before. Which of the eleven twitter times were you thinking of using? I note that only some of them use a url reference.

That’s how the template works. The filter says “if the the current tiddler has tag Person”, then do what’s inside the list tags. That’s where you put your twitter widget.

Edit:

Looks like you’re probably using the timeline type. So your widget might look like:

<$twitter type="timelineUrl" url={{!!twitter}}/>

Where twitter contains the url you want.

Edit 2:

The way I showed how to make a template tiddler is old-school. I think it’s easier for simple cases than the new way, which is to use cascades. But if you want, you can learn about how to do it with cascades here.

3 Likes

Example based off what i learned from Stephan Hradek’s simple contacts Db.

Awesome thank you. There are tons of different Twitter macros and yes being able to keep the full URL is easiest.

I’m writing this up “cleanly” in #tips-and-trick here

I’ll get to step by step screenshots too @john.edw_gmail.com — those are always super helpful.

All done on #Quine on my phone.

3 Likes