简体   繁体   中英

Add “edit article” button in joomla template

I created my own template for 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. You have to declare the User object properly:

So your code should start with:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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