Yes, that’s possible, but it escapes me at the moment.
I know you can get the ID in PHP using something. But I forgot what it was.
Using that, you could set the snippet in the template and use it like you propose.
Can anyone remember what the code was for the current document id?
$modx->documentIdentifier
greets Dimmy
So at the beginning of the snipper would I then need to set:
$parent = $modx->documentidentifier;
would this not just render the page that the snippet call is on, rather than the originating page?
Sorry, my PHP skills are slightly below rudimentary.
Theoretically, yes. BElow the <?php of course. Else it won’t work.
The point is that I’m not sure if that will return an ID or an Alias (if aliasses are enabled).
it will return the id of the current page
Whoopsie, that’s what you get for quick’n’dirty jobs. I forgot to write $modx->getDocument instead of just getDocument.
I’ve edited my ’orignal’ post. It just means that it’s not a global function. Which it isn’t, it’s a $modx function.
OK, that worked! Thanks.
I also managed to set $parent = $modx->documentIdentifier
However, the output PDF is now just a copy of the blank document with the makepdf snippet call. How can I implement it so that it creates a PDF of a document with content?
Well that depends on how you want to use it. Instead of setting the $par that way...
Hold on...
If you want to have a link in the template that calls that snippet, making a PDF of the current page, things get a little more complicated.
Pfff... Let me think. You’d have to make a page that takes a variable that the plugin can use as input (namely, the document ID). Unfortunately I have no idea how to do that exactly. Well, I know how to do it in PHP, but I’m not sure if it would work with rewrites.
Anyway, then you’d have to modify the snippet, again, to take that value as input. Say for example: $par = $_GET[’documentid’];
That would get the document id from the variable documentid, used like such: index.php?id=111&documentid=2
Where ID is the id of the page where you call the snippet and document ID is the page you want PDF-ed.
And... I THINK you could do this by adding the following link to the template: <a href="index.php?id=111&documentid=[*~id~*]">Get PDF</a>
Because, if I recall this all correctly, [*~id~*] gets replaced by the document ID of the page you’re viewing. This is all me thinking out loud, though ;-) Please forgive me if it blows up your computer. It shouldn’t as such... But you know, computers have been known to do stranger things.