Create Print or Share Article Popups with TypoScript

Oct 23, 2012
TypoScript Popup Links

The following TypoScript works pretty well if you have dedicated print and send to friend pages. However, if you have a dynamic print or email pages, this method isn’t so great.

This method assumes you’re using TemplaVoila’s alternate templates for print. Hence the &print=1.

Call the following into your template via TypoScript via lib.printLinks to use it in your template.

lib.print_url = TEXT
lib.print_url {
	value =  Print
       typolink {
               parameter = 261 640x480:status=1,menubar=1,scrollbars=1,resizable=1,location=1 - Print Story
               addQueryString = 1
               addQueryString {
                       method = GET
               }
               additionalParams = &print=1
       }
}
lib.tip_url = TEXT
lib.tip_url {
	value =  Email
       typolink {
               parameter = 210 1000x600:status=1,menubar=1,scrollbars=1,resizable=1,location=1 - Email Story
               addQueryString = 0
               addQueryString {
                       method = GET
               }
		additionalParams.cObject = COA
		additionalParams.cObject {
			# This part generates the "tipUrl" parameter in the
			# correct format. (rawUrlEncoded)
			10 = COA
			10 {
				# This part adds the domain (baseUrl) to the link URL
				10 = TEXT
				10.data = TSFE:baseUrl
				# This part creates an URL pointing to the current page
				# including all parameters from the query string.
				20 = TEXT
				20.typolink.parameter.data = page:uid
				20.typolink.addQueryString = 1
				20.typolink.addQueryString.exclude = id
				20.typolink.addQueryString.method = GET
				20.typolink.returnLast = url
				# Then everything is rawUrlEncoded so it can
				# be placed as a single parameter in the link URL
				stdWrap.rawUrlEncode = 1
			}
			# And finally the parameter data is wrapped with the "&tipUrl=" parameter.
			wrap = &tipUrl=|
		}
       }
}
### articleLinks
temp.articleLinks = COA
temp.articleLinks {
  ### Printlink
  10 < lib.print_url
  20 = HTML
  20.value =
  60 < .20
  70 < lib.tip_url
  80 < .20
}
lib.printLinks < temp.articleLinks

Alternately, for print pages, you could use CSS to hide the unneeded elements in your current template when printing and to avoid the need to have a specific print page.

See these scripts in action at ManhattanReview.com.

References

  • TSref TEXT
  • TSref typolink
  • TemplaVoila – A Print Version

Related Links

Originally posted 2009/03/03

Related Entries

Donate for Good Karma

Your donation helps enable Aihrus's volunteer efforts towards mentoring young developers and supporting Open Source projects.

No money? Leave a testimonial for Aihrus instead.

×

Log In


Need an account? Register
Forgot your password? Recover

Guest Purchase?

If you purchased as a guest, then you need to convert to a real account before accessing your purchases.

×

Register


Already registered? Log In

×