1

I want to use the module Shine pdf to generate pdf's. Only problem is it doesn't render embed tags in the template.

I would like to change the code in the module so it would render embed tags. This option would save me tons of time. Could someone push me in the right direction into what EE function I should use for this?

2

What you're looking to do is far from trivial, however....

Lets simplify first. Forget the pdf module, I assume you want to render your embed (and any other) tags and push the result into your pdf document (or anywhere else). In short you want EE Template in, Html Out.

We can actually achieve this prior to the PDF creation, and avoid heavy modification of the module, after all you don't know how they could be parsing in the module, in the best case it'll be a normal tag renderer but as the parse order shows the Shine PDF tag will be processed long before your embed.

So, with some clever PHP you can re-use the EE Template engine, we can render the EE template using the Template engine and output it onto the template before the module tags, like so :

PHP on parsed on input

<?php
  //this is the template code you wish to parse early into the pdf
  $str = "{embed='group/template' embedvar='true'}";
  ee()->TMPL->parse($str);
?>
{exp:shine_pdf:make}
  <?php echo $str; ?>
{/exp:shine_pdf:make}

This should parse the $str as if it was part of the template you are on at the moment (so your globals, variables etc should be available).

This is untested please note, so you may have to debug, however the concept is sound (used it before). Also note I've never used Shine PDF before but I'm assuming its a case of 'put your content between the tags', so I've put {exp:shine_pdf:make} tags in for example.

6
  • Thank you for your clear answer. Really appreciate it. I see where you are getting at. When I try your code without the shine tags it works as expected. Unfortunately when I add the shine tags I am getting <?php echo $str; ?> in the pdf. I guess this is parsing php on output which comes after parsing modules? – Balloonatic Jul 3 '15 at 12:25
  • I changed the PHP Parsing Stage on the template to "input" and now the embed tags are rendering. Thank you for your help! – Balloonatic Jul 3 '15 at 13:11
  • Glad I could help, I did put on my answer (above the snippet) to set the PHP arsing on input but you got is in the end :) – Blatant Jul 3 '15 at 16:24
  • PS> Thanks for correcting my poor-ass typing skillz Balloonatic! – Blatant Jul 3 '15 at 16:29
  • Now I see it. I totally missed it. Probably because I never use PHP in the templates and wasn't aware of the input or output parsing. – Balloonatic Jul 6 '15 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.