Forum Replies Created

Viewing 15 replies - 1 through 15 (of 30 total)
  • Plugin Author divinenephron

    (@divinenephron)

    Hi Webnerd,

    One way of doing this would be to add all the posts of a particular author to a category manually, then display the appropriate category when the user is logged in.

    If you put every posts into a category named after each user’s numerical ID, the code would look a little like this (the code hasn’t been tested):

    <?php if( function_exists('get_latex_url')
              && $user_id = get_current_user_id()
              && $user_latex_url = get_latex_url( 'term', $user_id, 'category' ) ): ?>
    <a href="<?php echo $user_latex_url ?>">PDF of logged in user's posts</a>
    <?php endforeach; ?>

    This was based on the code in the FAQ.

    You could modify the plugin to collate a user’s posts in the same way it collates categories and tags. This would require rather more skill and effort right now, but would save you from having to manually put posts into categories. I don’t intend to add anything to this plugin, so I won’t make this change myself.

    Plugin Author divinenephron

    (@divinenephron)

    Thanks for the bug report Malshar.

    According to this Stackoverflow answer I’ve erroneously put the & in the add_controller method call, when it should be in the method definition. I presume most versions of PHP only warn about this, while your throws an error for some reason.

    I will shortly upload version 1.3 of Latex Everything, which has this corrected. It might fix your error – tell me if it does.

    When I say Latex Everything supports up to WordPress 3.4.2, that means it’s been tested up to that version. It may work on later versions, but I haven’t tested this. If you discover bugs while using a version newer than 3.4.2 I’ll still do my best to fix them, but I don’t plan to test the plugin myself or change the supported version of WordPress listed in the description.

    Plugin Author divinenephron

    (@divinenephron)

    Does that answer your question?

    Plugin Author divinenephron

    (@divinenephron)

    Latex Everything is a plugin written in PHP to generate PDFs using Latex and help you link to them in WordPress themes. It doesn’t attempt to email them. However, the PDFs are just normal PDFs files, so you can do anything you want with them, including attaching them to emails. You’ll have to write your own WordPress plugin in PHP to do the emailing.

    See the WordPress documentation for how to write a WordPress plugin.

    See this Stack Overflow question for how to attach a PDF to an email in PHP.

    To attach a PDF generated by Latex Everything to an email, you’ll need to know its file path. I think you’ll be able to do that with code like this:

    get_attached_file(get_latex_attachment_id( $type, $arg1))

    for example, to get the filename of the current post while in The Loop:

    get_attached_file( get_latex_attachment_id('single_post',
                                               get_the_ID()) )

    NB: These code samples have not been tested, so I can’t guarantee they’ll work.

    See the documentation for get_attached_file and the Latex Everything FAQ to find out how the functions I’ve used work.

    Plugin Author divinenephron

    (@divinenephron)

    Ok, I’m quite sure Latex Everything isn’t designed to do that, and trying to make it do that is unnecessarily complex. I’ll leave it up to you to decide whether or not WordPress will make your life easier. Writing a normal PHP (i.e. without WordPress) that does what you described is probably the best way to start in either case. Use the TCPDF library, since FPDF hasn’t been maintained since 2011. Learning to use the library is, of course, also up to you.

    Good luck.

    Plugin Author divinenephron

    (@divinenephron)

    I ask because, based on the questions you’re asking, it sounds like you think Latex Everything does things it isn’t designed for. It also sounds like you’ll have to learn a lot of new things (how WordPress works, how Latex works, how to administer a Unix server) in order to make Latex Everything work, so using something simpler is likely to get you a faster and more reliable result. That’s why I asked “what’s the original problem” – if I know your original problem I can suggest something simpler. An “original problem” is something like “I want visitors to my website to be able to print my posts in a way that looks good”. “I want to create a PDF with PHP and Latex” is not an original problem, it’s a way of solving a problem, and for you I think it’ll be an unneccisarily difficult way to solve whatever you’re trying to do. So, what’s your original problem?

    Plugin Author divinenephron

    (@divinenephron)

    What are you trying to put into the PDF?

    Plugin Author divinenephron

    (@divinenephron)

    It sounds like you’re barking up the wrong tree with Latex Everything. What’s the original problem you’re trying to solve? If you’re trying to automatically generate PDFs of your blog, but don’t care whether you use Latex, there are simpler plugins to do that. If you’re trying to programatically generate PDFs of some other data outside WordPress, then neither WordPress nor any of its plugins are likely to help you, though I might be able to suggest some software that can.

    Plugin Author divinenephron

    (@divinenephron)

    Latex Everything has a default Latex template. I’m happy to tell you how to make your own, but I’d first like to check whether you’ve managed to create PDFs and link to them using the default template as described in the installation instructions?

    Plugin Author divinenephron

    (@divinenephron)

    There’s quite a lot of code shown in the FAQ; if that’s not enough for you, could you give a more detailed description of what you want to see?

    Plugin Author divinenephron

    (@divinenephron)

    If you want a PDF containing selected posts you can use categories. Generate PDFs of categories by following the “How do I typeset things besides posts?” instructions in the FAQ. Then put the selected posts the same category. This should create a PDF for the category.

    Add a link to the category’s PDF by putting code like this in your theme (this code is adapted from the stuff in the FAQ).

    <?php if( function_exists('get_latex_url') :
          foreach( get_the_category() as $category ) :
              if( $latex_url = get_latex_url('term', $category->cat_ID, 'category') ) : ?>
    <a href="<?php echo $latex_url ?>">PDF for <?php echo $category->name ?></a>
    <?php endif; endforeach; endif; ?>

    (This code hasn’t been tested, so it might contain errors)

    Plugin Author divinenephron

    (@divinenephron)

    Both of these bugs have been fixed in the 1.2 release.

    The custom post types didn’t work because of a silly error, which has now been corrected.

    I found that the PDF for the post type named “Foo” would overwrite the post entitled “Foo”, and that a page named “Foo” would do the same. This is because they were all saved as foo.pdf. I’ve now changed where new PDFs are saved – post types are saved to all-foo.pdf while posts are saved to post-foo.pdf, page-foo.pdf, custom-foo.pdf etc. This only affects newly created PDFs, not old ones or updates to them. If you want an old PDF to be put into the new location, delete it in the Media Library (/wp-admin/upload.php) then re-create it.

    Plugin Author divinenephron

    (@divinenephron)

    Thanks for the good descriptions of those bugs, I’ll fix them soon.

    Plugin Author divinenephron

    (@divinenephron)

    As s_ha_dum suggested, this has been made presuming it’s being run on a *nix operating system, and I don’t plan to make it work on Windows myself. However, if you get it to work I’m happy to include your changes in the plugin and list you as an author.

    All the code for pdflatex and pdftk should be in the file class-latex-document.php.

    Find out which errors the plugin is producing by adding the following to the site’s wp-config.php:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);

    Errors should then appear in wp-content/debug.log. I’m happy to help if you don’t undertand what an error means.

    Plugin Author divinenephron

    (@divinenephron)

    Is the plugin producing errors? Find out by adding the following to wp-config.php to enable debugging:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);

    Try to generate a PDF again, and tell me if any errors appear in wp-content/debug.log.

Viewing 15 replies - 1 through 15 (of 30 total)