如何在Joomla中向JHtml添加引导类 [英] How to add a bootstrap class to JHtml in Joomla

查看:104
本文介绍了如何在Joomla中向JHtml添加引导类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来显示我从gravatar.com获取的图像,因此我想使用bootstrap CSS类使其更具吸引力.添加样式而不是显示图像后,它立即向我显示该图像的链接,当我重定向到该链接时,便可以看到该图像.为什么我得到这个?

I am using following piece of code to display an image which I am fetching from gravatar.com, so I want to use a bootstrap CSS class to make it more attractive. As soon as I add the style rather than showing the image it shows me the link to the image, when I redirect to the link I am able to see the image. Why I am getting this?

$html[] = JHtml::_('image', $grav_url,'class="img-circle"', JText::_('PLG_CONTENT_AVATAR'), null, true)

这里$grav_url是我要获取图像的url,而img-circle是我要使用的引导程序类.

Here $grav_url is the url I am getting for the image and img-circle is the bootstrap class that I want to use.

推荐答案

我相信您正在使用的库在这里:

I believe the library you're using is here:

https://github.com. com/joomla/joomla-cms/blob/staging/libraries/cms/html/html.php#L567

因此您可以在参数列表中看到$attribs的一个参数,其类型为数组.另一件事是您还必须传递一个附加的$ alt参数,这可能是您的jtext混乱了.要将其传递给方法,您将执行以下操作:

So you can see in the parameter list that there is a param for $attribs which is of the type array. The other thing is there is an additional $alt param you have to pass which might be your jtext just out of order. To pass that to the method you would do:

$html[] = JHtml::_('image', $grav_url, JText::_('PLG_CONTENT_AVATAR'), array('class'=>'img-circle'), true)

或者您可以在方法外将数组构建为变量:

Or you could build the array outside the method as a variable:

$attribs = array();
$attribs['class'] = 'img-circle'; // I think this should work? haven't tested though.

$html[] = JHtml::_('image', $grav_url, JText::_('PLG_CONTENT_AVATAR'), $attribs, true)

这篇关于如何在Joomla中向JHtml添加引导类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆