adding new module problem

amira - June 10, 2009 - 09:53

when i added a new(my owm) module it was ok and i tried to make it appeares in menu :

quotes.module
***********

function quotes_menu()
{
$items[]=array();
$items[]=array(
'path' =>'admin/settings/favorite/quotes',
'title' =>t("Manage favorite quotes"),
'description' => t("Add more favorite quotes"),
'callback' => 'drupal_get_form',
'callback arguments' => 'quotes_settings',
'access' => user_access('access administration pages')
);

return $items;
}

function quotes_settings()
{
$form["quotes_manage"]=array(
'$type'=>'fieldset',
'$title'=>t("Add New Quote"),
'$tree'=>TRUE
);
$form["quotes_manage"]["add"][0]=array(
'$type'=>'textfield',
'$title'=>t("Enter a Quote"),
'$description'=>t("Qualified quotes are only those are your favorite")
);
$form["quotes_manage"]["add"][1]=array(
'$type'=>'textfield',
'$title'=>t("Auther")
);
$form["$submit"] = array("quotes_get_form"=>array());

return system_settings_form($form);
}

function quotes_get_form($form_id,$form_values)
{
drupal_set_message(t("Submitted OK"));
}

but when i click on "Manage favorite quotes " it doesnot refresh to the page that contains the 2 text boxes and so on....so what is the expected problem??????????

*_*

beautifulmind - June 10, 2009 - 10:03

hook_menu() re-written for 6.x

function quotes_menu()
{
$items[]=array();
$items['admin/settings/favorite/quotes']=array(
'title' =>t("Manage favorite quotes"),
'description' => t("Add more favorite quotes"),
'page callback' => 'drupal_get_form',
'page arguments' => 'quotes_settings',
'access callback' => user_access('access administration pages')
);

return $items;
}

Regards.

do u mean that , i write

amira - June 10, 2009 - 11:12

do u mean that , i write function hook_menu() instead of quotes_menu() ?

if the answer is yes,...i do that but the problem is still existing

*_*

beautifulmind - June 10, 2009 - 11:35

Nop, hook is a general term
for this matter it will be quotes_menu(), but you have to define the menus in Drupal 6.x way.

ok,but how i can define the

amira - June 10, 2009 - 11:37

ok,but how i can define the menus in drupal 6.x ???

*_*

beautifulmind - June 10, 2009 - 11:38

Check the very first reply. Also, look at http://api.drupal.org and type in 'hook_menu'

thanks for advance but, i

amira - June 10, 2009 - 11:50

thanks for advance
but, i follow up what it is recommended but there is the same problem :(

well, could i know the

amira - June 10, 2009 - 12:16

well,

could i know the meaning of this line:

function quotes_menu()
{
.....
.....
'path' =>'admin/settings/favorite/quotes',
.....
....
}

Location in admin menu

jasonnovember - June 10, 2009 - 22:42

It basically specified the location of the title of your module in the admin menu. In your case, your menu title will appear under admin->settings->favourite->quotes->"Manage favorite quotes"

In the updated api,

$items[]=array();
$items['admin/settings/favorite/quotes'] //This is used instead of "path"

This is incorrect. It should

mradcliffe - June 10, 2009 - 23:19

This is incorrect.

It should be...

<?php
function quotes_menu() {
 
$items = array();
 
$items['admin/settings/quotes'] = array( // favorite/quotes probably won't be accessible from site configuration menu if favorite doesn't exist
   
'title' => 'Manage favorite quotes',
   
'description' => 'Add more favorite quotes',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('quotes_settings'), // notice the array() here
   
'access callback' => 'user_access', // not a function call
   
'access arguments' => array('administer site configuration'), // these are your access arguments for user_access
   
'type' => MENU_NORMAL_ITEM
 
);
  return
$items;
}
?>

but when i click the"Manage

amira - June 11, 2009 - 06:49

but when i click the"Manage favorite Quotes" link it is supposed to load a page that contains 2 textboxs by calling the function quotes_settings() ,but that is didnot happen??????

function quotes_settings()
{
$form["quotes_manage"]=array(
'$type'=>'fieldset',
'$title'=>t("Add New Quote"),
'$tree'=>TRUE
);

$form["quotes_manage"]["add"][0]=array(
'$type'=>'textfield',
'$title'=>t("Enter a Quote"),
'$description'=>t("Qualified quotes are only those are your favorite")
);

$form["quotes_manage"]["add"][1]=array(
'$type'=>'textfield',
$title'=>t("Auther")
);

$form["$submit"] = array("quotes_get_form"=>array());

return system_settings_form($form);
}

function quotes_get_form($form_id,$form_values)
{
drupal_set_message(t("Submitted OK"));
}

so plzz tell me what is the problem on that...........

thanks in advance

*_*

beautifulmind - June 11, 2009 - 07:32

Read the hand book for how to create forms.
The code for the form you've written doesn't seem like a Drupal form

 
 

Drupal is a registered trademark of Dries Buytaert.