简体   繁体   English

在joomla模板中添加“编辑文章”按钮

[英]Add “edit article” button in joomla template

I created my own template for Joomla 3.0. 我为Joomla 3.0创建了自己的模板。

I'd like to display an edit button on any page (as the default template does) for every users with the right permission in order but I can't figure out how to enable it. 我想为每个具有正确权限的用户在任何页面上显示一个编辑按钮(就像默认模板一样),但是我不知道如何启用它。

Any idea ? 任何想法 ?

Edit : 编辑:

I tried to add this on my template index : 我试图将其添加到我的模板索引中:

<?php if ($this->user->authorise('core.edit', 'com_content.article.'.$this->item->id)) : ?>
<li class="edit-icon"><?php echo JHtml::_('icon.edit', $this->item, $params); ?></li>
<?php endif; ?>

but I got the following error : 但我收到以下错误:

Fatal error: Call to a member function authorise() on a non-object

It doesn't recognize the User object. 它无法识别User对象。 You have to declare the User object properly: 您必须正确声明User对象:

So your code should start with: 因此,您的代码应以以下内容开头:

$user = JFactory::getUser();
<?php if ($user->authorise('core.edit', 'com_content.article.'.$this->item->id)) : ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM