[development] url as callback argument
Paolo Mainardi
paolomainardi at gmail.com
Tue Feb 3 11:37:29 UTC 2009
On Tue, Feb 3, 2009 at 11:34 AM, cooper Quintin <cooperq at cooperq.com> wrote:
> Hello all,
> I am writing a module and I am trying to use a url as a callback
> argument, but it does not work. Here is the code:
>
> $items[] = array(
> 'path' => 'admin/settings/featured-comments/feature',
> 'title' => t('featured comment'),
> 'callback' => 'feature_comment',
> 'callback_args' => $_GET['cid'],
> 'access' => user_access('administer comments'),
> 'type' => MENU_CALLBACK
> );
>
> and the callback function:
> function feature_comment($cid) {
> $comment = _comment_load($cid);
> db_query("UPDATE {featured_comments} SET featured=1 WHERE cid=%d", $cid);
> drupal_goto("node/$comment->nid");
> }
>
I think you can bypass the problem loading the $_GET in feature_comment
function and obviously setting $cid = NULL, so:
function feature_comment($cid = NULL) {
if (!isset($cid)) {
if (!$cid = $_GET['cid']) {
drupal_goto();
}
}
$comment = _comment_load($cid);
db_query("UPDATE {featured_comments} SET featured=1 WHERE cid=%d", $cid);
drupal_goto("node/$comment->nid");
}
--
Paolo Mainardi
Vice Presidente Assoc.ILDN (http://www.ildn.net)
Blog: http://www.paolomainardi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20090203/eb1f5d03/attachment.htm
More information about the development
mailing list