Snippet: Template logic to provide users with printable search layout


I was recently updating an eZ publish search implementation. I noticed that the site design used a print icon in it's page layout, yet sadly it was hard coded to only work on page views which displayed node content. (statically linked to for content view full + node_id).

On page views using the search (displaying results) the printable link naturally did not function and would link to an incomplete url. Leading me to sneaking implementing alternate printable views (other than 'view') like advanced search (results).

Yet I ran into a problem of how to do this the 'eZ' way, this must have been done before (dynamic printable link for alternate module views :\)

The Question

How to detect in $module_result or other template variable when using the '/content/advancedsearch/' module as apposed to 'view'.

Using the above solution, then how would you create a print this page link (#1) which passes the search url parameters to a printer friendly template layout and navigator.

The first answer found

On and in the demo the printer version link made no sense on search, only printing without results where possible.

Change the code in page_layout_section_xxx.tpl or where else into:

{section show=$enable_print}
{section show=is_set($search_text_enc)}
{section show=is_set($search_contentclass_id)}
<a href={concat('layout/set/print/',$site.uri.tail,'?SearchText=',$search_text_enc,'&SearchContentClassAttributeID=',$search_contentclass_id,'&SearchSectionID=',$search_section_id,'&SearchDate=',$search_date)|ezurl} class="path">{'Printable version'|i18n('design/standard/layout')}</a>
<a href={concat('layout/set/print/',$site.uri.tail,'?SearchText=',$search_text_enc)|ezurl} class="path">{'Printable version'|i18n('design/standard/layout')}</a>
<a href={concat("layout/set/print/",$site.uri.tail)|ezurl} class="path">{'Printable version'|i18n('design/standard/layout')}</a>

A second answer

Do the print with only a css (media=print). It works fine.


Forum: Printable Search in eZ