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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看