ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Printing a template from another template

November 30, 2011 5:45am

Subscribe [3]
  • #1 / Nov 30, 2011 5:45am

    Kippi

    83 posts

    Hi,
    I was wondering if anyone know of a way to print a particular template from another template.

    Say I have a template that shows a list of news articles: Title, Summary

    and a template that shows the single entry: Title, Summary, Body.

    I want to have a “print link” accompany the article on the first template that prints the single entry.

    Regards, Kippi

  • #2 / Dec 01, 2011 4:27am

    John Henry Donovan

    12339 posts

    hi Kippi,

    You could use the {title_permalink} tag like this where news is your template group name and print is the template where you have the print version of your entry

    <a href="http://{title_permalink=">print me</a>

    This would generate a URL like this

    <a href="http://www.mydomain.com/index.php/news/print/name_of_my_article">http://www.mydomain.com/index.php/news/print/name_of_my_article</a>

    Does that help?

  • #3 / Dec 01, 2011 4:48am

    Kippi

    83 posts

    Hi, thanks for the reply but that would simply link to another template.

    I was thinking more of an auto generated “Print” link.

  • #4 / Dec 01, 2011 4:52am

    John Henry Donovan

    12339 posts

    Kippi,

    EE doesn’t get in the way of how you wish to print your website pages. Take a look here for a generous list of techniques which should help

  • #5 / Dec 01, 2011 5:07am

    Kippi

    83 posts

    UPDATE!

    I found a jquery solution that seems to work pretty much to what I need.

    Posting a link below if anyone is interested.

    jQuery-printPage-plugin

    http://tinyurl.com/cp5tgur

    ———————

    Thanks for the link:-)

    I think Ill do it like you suggested but add some javascript to bring up the print dialogue box on page load.
    I havn´t tested it crossbrowser yet though

    function PrintWindow()
            {                     
               window.print();            
               CheckWindowState(); 
            }
            
            function CheckWindowState()
            {            
                if(document.readyState=="complete")
                {
                    window.close();  
                }
                else
                {            
                    setTimeout("CheckWindowState()", 2000)
                }
            }    
            
           PrintWindow();
  • #6 / Dec 05, 2011 7:40pm

    Kevin Smith

    4784 posts

    Hey, great solution, Kippi! Thanks for posting it back here for the benefit of all. If there’s anything else we can do to help, feel free to let us know!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases