Using variables inside of square brackets to link to external files.

148 views
Skip to first unread message

Jack Stephan

unread,
Jan 4, 2019, 7:51:00 AM1/4/19
to TiddlyWiki
Hello, thanks in advance for any help. I'm still quite a new user so I don't know if I'm phrasing the question in a way that meaningful, but I'll try my best. I am trying to incorporate all the PDFs from my lectures into TiddlWiki and link to them and specific pages. Is there a way to use this form of linking to PDFs:

 [ext[linkName|files/POD_5_MLST.pdf#page=8]]

and to make the link name (linkName) page number (8) and the PDF title (POD_5_MLST.pdf) variables in some sort of macro? Ideally the macro would have three inputs, the desired title (linkName), the primary key of the PDF tiddler (labelled as field FID) which would call the PDF file name (another field called filename), and the page number to link to? For example:

<<pdflink 'Existential Quaintifier' 'POD5' '8'>>

To illustrate the structure of my PDF tiddlers, here is an example:
fidPOD5
filenamePOD_5_MLST.pdf
lecturetitleMathematical Logic & Set Theory
pdfpdf
scodePOD
tags[[Principles of Databases]]
tcode
titlePOD_5_MLST.pdf
typelecture


Again, thanks for the help. I hope I have explained my question well enough, but again, I think I am still in the learning phase where it is difficult to ask the 'right' questions.

Mohammad

unread,
Jan 4, 2019, 9:45:42 AM1/4/19
to TiddlyWiki
Jack
This is not difficult. You can add suffix or prefix to the file name, so you can create the filename.

If I can find in forum, there is a similar question answered by Mark S.

I will share it.

Mohammad

Mohammad

unread,
Jan 4, 2019, 11:09:28 AM1/4/19
to TiddlyWiki
Jack,
 See this wonderful solution by Mark S.

It creates external images from a directory. Your case is very much the same.

Cheers
Mohammad

Jack Stephan

unread,
Jan 6, 2019, 9:27:18 AM1/6/19
to TiddlyWiki
Unfortunately I'm still confused. The concept may be in the answer provided somewhere, but I'm having trouble seeing where. The problem isn't that I want to create tiddlers from my PDFs with a button. I already have the pdfs imported as individual tiddlers with the fields shown above. My problem is that I was to be able to write notes and link to specific pages of my pdfs in the notes. For example:

This some text about my lectures, in order to better understand here is a [[Link]] to the specific page of the lecture I am discussing.

But I want that link to be a function with three arguments, as stated above i.e. a title to be displayed in the text, the primary key (fid) of the tiddler, and the page number to link to.

Thank for your help, Mohammad, I greatly appreciate it.

Mark S.

unread,
Jan 6, 2019, 3:14:24 PM1/6/19
to TiddlyWiki
Untested, but this should work (you may need to tweak the path, etc)

\define pdflink(name path page)  [ext[$name$|files/$path$.pdf#page=$page$]]

Good luck
-- Mark

Jack Stephan

unread,
Jan 7, 2019, 6:55:36 AM1/7/19
to TiddlyWiki
Hi Mark,

Thank you. This what I am looking for. One final question, is there a way to have my input to $path$ be the field of a tiddler i.e. title or else a user-defined field, but the actual path itself (another user-defined field) populates?

Again, I really appreciate the help. I'm still getting the hang of this,
Jack

Mark S.

unread,
Jan 7, 2019, 10:12:48 AM1/7/19
to TiddlyWiki
In this version, the base path is defined in a tiddler, mypathtiddler. It could be defined in a field of a tiddler, but this way is a little more transparent:

\define pdflink2(name path file page)  [ext[$name$|$path$/$file$.pdf#page=$page$]]
\define pdflink(name file page) <$macrocall $name=pdflink2 name="""$name$""" path={{mypathtiddler}} file="""$file$""" page="""$page$"""/>

<<pdflink "grammar" "Spanish_Grammar" "2">>

Good luck!
-- Mark

Jack Stephan

unread,
Jan 7, 2019, 12:39:03 PM1/7/19
to TiddlyWiki
Mark,

Thanks a million. This clarifies everything for me. 

Jack
Reply all
Reply to author
Forward
0 new messages