dsc56927 2014-08-11 02:21
浏览 45
已采纳

如何在joomla 2.5自定义组件中添加电子邮件/打印

Kindly explain me how to add email/print icon in my component (joomla 2.5).

I am able to accomplish it partially but i cannot print plus this is not a standard way i guess. The print icon and email icon is missing.

<a href="<?php echo JRoute::_('index.php?option=com_mailto&tmpl=component&&template=shape5_vertex&link=ffc8df4efb9cbf37a836ddfeb67f6d0df4155699'); ?>" title="Email" onclick="window.open(this.href,'win2','width=400,height=350,menubar=yes,resizable=yes'); return false;"><img src="/joomla/media/system/images/emailButton.png" alt="Email"  /></a>
<a href="<?php echo JRoute::_('index.php?option=com_mycomp&view=comps&tmpl=component&print=1'); ?>" title="Print" onclick="window.open(this.href,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'); return false;" rel="nofollow"><img src="/joomla/media/system/images/printButton.png" alt="Print"  /></a>      
  • 写回答

2条回答 默认 最新

  • dsljpwi494719 2014-08-11 23:37
    关注

    In a recent project I used the below Joomla Docs tutorial successfully to add print functionality.

    You must construct the your URL like so:

    <?php
        $isModal = JRequest::getVar( 'print' ) == 1; // 'print=1' will only be present in the url of the modal window, not in the presentation of the page
        if( $isModal) {
                $href = '"#" onclick="window.print(); return false;"';
        } else {
                $href = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
                $href = "window.open(this.href,'win2','".$href."'); return false;";
                $href = '"index.php?option=mycomponent&view=myview&tmpl=component&print=1" '.$href;
        }
    ?>
        <a href=<?php echo $href; ?> >Click for Printing</a>
    

    The same code will render the link in view and in the resulting modal window with the same Click for Printing, except when the user clicks the button in the modal window it will open the browsers print window.

    You of course need to adjust the code with relevant component and view information for your project.

    http://docs.joomla.org/Adding_print_pop-up_functionality_to_a_component

    * EDIT *

    Be sure to add the following line to the top of the view file:

    JHtml::_('behavior.modal');
    

    * EDIT 2 *

    I reviewed the sample code and one from a working project I had and noticed one glaring ommission. I had failed to define the URL parameter for view. I adjusted the above code snippet (inside else, third $href variable) to reflect change.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了