添加图像到 Joomla JToolBar 自定义链接按钮

发布于 2024-09-30 11:02:26 字数 272 浏览 0 评论 0原文

您好,我在组件的管理部分创建了一个自定义按钮链接,如下所示:

$bar = & JToolBar::getInstance('toolbar');
$bar->appendButton( 'Link', 'export', 'Export', 'index.php?option=com_component&task=export&format=raw' );

但是没有为其分配图像,我不知道如何为按钮分配图像。有谁知道我该怎么做?

Hi I have created a custom button link in the admin section of my component, something like this:

$bar = & JToolBar::getInstance('toolbar');
$bar->appendButton( 'Link', 'export', 'Export', 'index.php?option=com_component&task=export&format=raw' );

However no image is assigned to it and I don't know how to assign one to the button. Does anyone know how I can do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春庭雪 2024-10-07 11:02:26

您需要创建带有图像背景的名为 icon-32-export 的 CSS 类。

这是一个例子:

<?php

// Add CSS class to the document, it's better to have it in external CSS document
$imgPath = JRoute::_('/administrator/templates/khepri/images/toolbar/icon-32-new.png');
JFactory::getDocument()->addStyleDeclaration(".icon-32-export { background: url($imgPath); }");

//
$bar = & JToolBar::getInstance('toolbar');
$url = JRoute::_('index.php?option=com_component&task=export&format=raw');
$bar->appendButton( 'Link', 'export', 'Export', $url);

?>

You need to create CSS class called icon-32-export with image background.

Here is an example:

<?php

// Add CSS class to the document, it's better to have it in external CSS document
$imgPath = JRoute::_('/administrator/templates/khepri/images/toolbar/icon-32-new.png');
JFactory::getDocument()->addStyleDeclaration(".icon-32-export { background: url($imgPath); }");

//
$bar = & JToolBar::getInstance('toolbar');
$url = JRoute::_('index.php?option=com_component&task=export&format=raw');
$bar->appendButton( 'Link', 'export', 'Export', $url);

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文