like you can edit ordinary pages by using the {edit} tag. I have made a plugin that implements this idea:
This {edit_news} tag is based on the {edit} tag, but is adapted to be used in News templates.
Code: Select all
<?php
function smarty_cms_function_edit_news($params, &$smarty)
{
global $gCms;
if (!check_permission(get_userid(false), 'Modify Any Page'))
return;
$text = isset($params['text']) ? $params['text']:'Edit This Article';
$id = $params['id'];
return '<a target="_blank" href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/moduleinterface.php?mact=News,m1_,editarticle,0&m1_articleid='.$id.'"><img
align="left" src="'.$gCms->config['root_url'].'/images/cms/editbutton.png" alt="'.$text.'"/></a>';
}
function smarty_cms_help_function_edit_news() {
?>
<h3>What does this do?</h3>
<p>Creates a link to edit the news article</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your News template like: <code>{edit2 showbutton='true' id=$entry->id}</code>
<h3>What parameters does it take?</h3>
<ul>
<li><em>(required)</em> id - News article id.</li>
<li><em>(optional)</em> text - text to show on hoover.</li>
</ul>
<?php
}
function smarty_cms_about_function_edit_news() {
?>
<p>Author: Gaute Sandvik</p>
<p>Version: 1.0</p>
<p>This {edit_news} tag is based on the {edit} tag, but adapted to be used in News templates.</p>
Change History:<br/>
<p>
none
</p>
<?php
}
?>
It is also possible to merge this functionality into the existing edit tag, like this:
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function smarty_cms_function_edit2($params, &$smarty)
/*
global $gCms;
if (!check_permission(get_userid(false), 'Modify Any Page')
&& !quick_check_authorship($gCms->variables['content_id'],
author_pages(get_userid(false))))
return;
$text = isset($params['text']) ? $params['text']:'Edit This Page';
if (isset($params["showbutton"]))
{
return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/editcontent.php?content_id='.$gCms->variables['content_id'].'"><img
src="'.$gCms->config['root_url'].'/images/cms/editbutton.png" alt="'.$text.'"/></a>';
}
else
{
return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/editcontent.php?content_id='.$gCms->variables['content_id'].'">'.$text.'</a>';
}
*/
{
global $gCms;
if (!check_permission(get_userid(false), 'Modify Any Page')
&& !quick_check_authorship($gCms->variables['content_id'],
author_pages(get_userid(false))))
return;
$text = isset($params['text']) ? $params['text']:'Edit This Page';
if (isset($params["showbutton"]))
{
if(isset($params['id']))
{
return '<a target="_blank" href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/moduleinterface.php?mact=News,m1_,editarticle,0&m1_articleid='.$params['id'].'"><img
align="left" src="'.$gCms->config['root_url'].'/images/cms/editbutton.png" alt="'.$text.'"/></a>';
}
else
{
return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/editcontent.php?content_id='.$gCms->variables['content_id'].'"><img
src="'.$gCms->config['root_url'].'/images/cms/editbutton.png" alt="'.$text.'"/></a>';
}
}
else
{
if(isset($params['id']))
{
return '<a target="_blank" href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/moduleinterface.php?mact=News,m1_,editarticle,0&m1_articleid='.$params['id'].'">'.$text.'</a>';
}
else
{
return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].
'/editcontent.php?content_id='.$gCms->variables['content_id'].'">'.$text.'</a>';
}
}
}
function smarty_cms_help_function_edit2() {
?>
<h3>What does this do?</h3>
<p>Creates a link to edit the page.</p>
<h3>How do I use it?</h3>
<h4>Webpages</h4>
<p>Just insert the tag into your web template/page like: <code>{edit2 showbutton='true'}</code>,<br>
or you can apply it in your News templates like: <code>{edit2 showbutton='true' id=$entry->id}</code>
<h3>What parameters does it take?</h3>
<ul>
<li><em>(optional)</em>showbutton - Set to "true" and will show a edit graphic instead of a text link.</li>
<li><em>(optional)</em>text - Set this to change default text.</li>
<li><em>(required for news articles)</em> id - News article id.</li>
</ul>
<?php
}
function smarty_cms_about_function_edit2() {
?>
<p>Author: Sorin Sbârnea<sorin2000@intersol.ro> (remove 2000 from address)</p>
<p>Version: 2.0</p>
<p>
Change History:<br/>
<ul>
<li>
This is a modified version of the {edit} tag.<br/>
Modifications made by Gaute Sandvik, gaute_sandvik@c2i.net, 04 april 2008: <br/>
- id parameter added to be used with News articles.
</li>
</ul>
</p>
<?php
}
?>
GDS