[英]how to add email/print in joomla 2.5 custom component
請向我解釋如何在我的組件(joomla 2.5)中添加電子郵件/打印圖標。
我能夠部分完成它,但是我無法打印,而且我猜這不是標准方法。 缺少打印圖標和電子郵件圖標。
<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>
這就是我的:
<?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=com_mycomp&view=comps&tmpl=component&print=1&layout=default&page="'.@ $request->limitstart.'"'.$href;
}?><a href="<?php echo $href; ?>"><img src="templates/shape5_vertex/images/system/printButton.png" alt="Print" /></a>
在最近的項目中,我成功使用了下面的Joomla文檔教程,以添加打印功能。
您必須這樣構造您的URL:
<?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>
相同的代碼將以相同的Click for Printing在視圖和最終的模式窗口中呈現鏈接,但當用戶單擊模式窗口中的按鈕時,它將打開瀏覽器的打印窗口。
當然,您需要使用相關組件來調整代碼並查看項目的信息。
http://docs.joomla.org/Adding_print_pop-up_functionality_to_a_component
*編輯*
確保將以下行添加到視圖文件的頂部:
JHtml::_('behavior.modal');
*編輯2 *
我查看了示例代碼和一個工作項目中的示例代碼,發現其中一個明顯的遺漏。 我未能為視圖定義URL參數。 我調整了上面的代碼段(在其他位置,第三個$ href變量)以反映更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.