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条)

报告相同问题?

悬赏问题

  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具