How to add print option to any plugin / Tip and tricks / Forums - e107.sk











































		

How to add print option to any plugin / Tip and tricks / Forums


  • Adding print options has 2 parts:
    1. add button with option /link to print displayed page
    2. solve printing itself.

    Adding print button


    Already existing print button in core:
    news: -
    new way

    {PRINTICON}
    {PRINTICON: class=btn btn-default}

    forum: -
    semiold way

    {PRINTITEM}

    PRINTICON
    require_once(e_HANDLER.'emailprint_class.php');
    return emailprint::render_emailprint($plugin_name, $record_id, 2, $parm);
    note:
    this shortcode can be used only for news. There are attemps to make it as general solution, but it's not finished, print.php still counts of text "plugin" in first parameter.

    {PRINTITEM}
    using single shortcode 
    {PRINT_ITEM=Print^plugin:forum. $record_id}

    for any of this way link for printing is created this way:
    href='".e_HTTP."print.php?".$print.".".$record_id."' where $print is 'news' or plugin:$plugin_name

    For custom plugin is maybe better direct method (
    old way
    )
    Note: I don't see point to call shortcode, then template for next shortcode inside.

    Example:
    {REVIEWER_VIEW_PRINT} - custom shortcode

    SC_BEGIN REVIEWER_VIEW_PRINT
    global $reviewer_reviewer_ep;
    $reviewer_print .= " <a href='../../print.php?plugin:reviewer.$reviewer_reviewer_ep' title='" . REVIEWER_V022 . "'><img src='" . e_IMAGE . "generic/" . IMODE . "/printer.png' style='border:0;' alt='" . REVIEWER_V022 . "' /></a>";
    return $reviewer_print;
    SC_END

    Note:
    There is still used
    ICONPRINT with path THEME."images/".ICONPRINT
    or
    e_IMAGE_ABS."generic/printer.png";
    and
    hardcoded glyphicon icons:
    <span class='glyphicon glyphicon-print' aria-hidden='true'></span>

    Printing itself

    Printing is managed by print.php file.

    Each printable plugin has to have e_emailprint.php addons. Function print_item() defines what is printed.

    News are exception, news are reading directly in print.php and news_template is used for output.

    Print.php can use THEME.'print_template.php'
    there is no core print_template.php file.

    If template doesn't exist, it just display print content with white background and button with window.print().

    Note:
    old Reviewer plugin is example of fully customized solution for plugin with printing option.
     

Moderator(s):
Search just forum
Chatbox
You must be logged in to post comments on this site - please either log in from the Login box or from here.If you are not registered click here to signup.


  • Jimako
    Jimako  1 week ago

    After 2 days I was able to create demo of BS Magazine 01 theme:
    https://v2demo.e107.sk/magazine01/

  • Jimako
    Jimako  1 week ago

    My antivirus software blocked and disabled gitter.

  • Jimako
    Jimako  2 weeks ago

    Again, I had to set tinymce off. It strips custom bbcodes.

  • Jimako
    Jimako  3 weeks ago

    Sorry, I set login off by mistake, it should be fixed now.

  • Jimako
    Jimako  1 month ago

    I just notice on contact form GDPR agreement. Funny thing is that site doesn't store any submitted information.