XH 1.6: adding function to get URL for print view

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

XH 1.6: adding function to get URL for print view

Post by cmb » Mon Sep 16, 2013 9:04 pm

Hello Community,

CMSimple offers the function printlink() to insert a link to the print view in the template. One can change the link text by changing $tx['menu']['print']. However, a not so uncommon requirement is to use an image instead of a text. It is possible to use the following:

Code: Select all

tx['menu']['print']="<img src="\path/of/image\" alt="print view">";
That works, but it's not nice to change the language settings of several languages to show the same image, and one would have to adapt it according to $cf['xhtml']['endtags'] (the latter being especially annoying for template designers who want to offer (X)HTML conforming templates).[1]

We may consider offering a function that returns the URL of the print view instead of the complete link additionally. Then it would be possible to write in the template:

Code: Select all

<a href="<?php echo XH_printUrl();?>"><?php tag('img src="' . $pth['folder']['templateimages'] . 'print.png" alt="'  . $tx['menu']['print'] . '');?></a>
[1] Well, I'm aware that one could write something like:

Code: Select all

$tx['menu']['print']="tag('img src=\"' . $pth['folder']['templateimages'] . 'print.png\");";
However, I consider that a dirty hack, as it will not be handled as desired in the language settings form.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: XH 1.6: adding function to get URL for print view

Post by Holger » Thu Sep 19, 2013 4:26 pm

+1

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: XH 1.6: adding function to get URL for print view

Post by Tata » Wed Dec 04, 2013 7:40 pm

How about to add such icon/function in content?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: adding function to get URL for print view

Post by cmb » Thu Dec 05, 2013 1:13 pm

Tata wrote:How about to add such icon/function in content?
I'm not sure, what you mean. Can you please elaborate.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: XH 1.6: adding function to get URL for print view

Post by Tata » Thu Dec 05, 2013 3:52 pm

I mean to put an image-link to e.g. print(), sitemap() functions into the content instead into the template. There is it placed as a

Code: Select all

<?php echo printurl();?>
. On the page it shall be then something like

Code: Select all

<a href="..."><img src="..." alt="..."></a>
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: adding function to get URL for print view

Post by cmb » Tue Jan 21, 2014 2:35 pm

Tata wrote:I mean to put an image-link to e.g. print(), sitemap() functions into the content instead into the template.
Well, that is already possible. To have an image link to the sitemap in the content, simply insert an image and link that to ?sitemap. To have a respective print link, you can link to {{{XH_printUrl();}}}, if you don't want to hardcode the link or if you want to put this link in a newsbox page. The resulting HTML might be something like this:

Code: Select all

<a href="{{{XH_printUrl();}}}"><img src="./userfiles/images/printer.png" alt="" width="18" height="12"></a> 
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: XH 1.6: adding function to get URL for print view

Post by svasti » Tue Jan 21, 2014 10:17 pm

@ Christoph:
I hope you put all these tips and tricks into the WIKI. Otherwise how could anybody keep track of this. Or maybe we need a scribe . . .

I guess, Tata means adding some icons to the core. However I think that such icons rather belong to the template and could be different from template to template.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: adding function to get URL for print view

Post by cmb » Tue Jan 21, 2014 10:39 pm

svasti wrote:@ Christoph:
I hope you put all these tips and tricks into the WIKI. Otherwise how could anybody keep track of this. Or maybe we need a scribe . . .
I have already thought about putting this "trick" into the WIKI. However, it's not a special trick, it's just about using the plugin call as it's meant to work: replace the plugin call with the return value of the called function when in view mode. Another potential problem with having all those tricks in the WIKI: how's one able to find them?
svasti wrote:However I think that such icons rather belong to the template and could be different from template to template.
ACK.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply