i'v found some code that i wanted to try out, but i'm having problems of showing the content. The modules attempt is to generate a form which i have created and show this on a page, (admin/settings/ something /something), but when i push the button for the module in (admin/settings), it goes to (admin/settings/ something /something), but still shows the content of (admin/settings), and dont show the page with the form. Here the code:

// quotes.module

	function quotes_menu() { 
		$items = array();
		$items[quotes] = array( 
				'path' => 'admin/settings/favourite/quotes',
				'title' => t("Manage quotes"), 
				'description' => t("add more quotes"),
				'callback' => 'drupal_get_form',
        			             'callback arguments' => 'quotes_settings',
				'access' => user_access('access content')
		); 
		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 new quote")
	       );
                    $form["quotes_manage"]["add"][1] = array(
		'#type' => 'textfield',
		'#title' => t("Author")
	       );
	       $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"));
            }	

//quotes.info

; $Id$
name = quotes
description = favourite quotes
core = 6.x

Anybody who can see what the problem here might be?
Would be exstatic for any help:)

Comments

grobemo’s picture

I think the problems are in quotes_menu. I see two problems:

First, you need quotation marks around the keys in your $items (<?php $items['quotes'] ?> rather than <?php $items[quotes] ?>).

Second, I'm not sure what the 'path' setting is. I take it you're trying to tell Drupal what path you want to use to display your form. You do this as follows:

<?php

function quotes_menu() {
  $items = array();
  $items['admin/settings/favourite/quotes'] = array(
    // set your attributes here
  );

  return $items;
}
?>

In other words, you use the path as the key in $items. This way, when you go to yoursite.com/admin/settings/favourite/quotes, Drupal will return your form.

But note that every time you add or change a menu item's path, you need to rebuild the menu. The easiest way to do that is to clear the cache (either using the Devel module or by going to admin/settings/performance and clicking the button at the bottom).

If you haven't seen it already, the Drupal 6.x module developer's handbook is extremely useful. In particular, have a look at the section on the Drupal menu system

stinis87’s picture

thanks for the feedback!:) You made it a bit clearer, but i tried to rebuild the menu as u said by using the bottom cache button on settings/performance, but i still see unabled modules appearing there, how do i get them to dissapear?

grobemo’s picture

I'm not sure what you mean when you say that you "still see un[en]abled modules appearing there"? What exactly do you see, and where?

stinis87’s picture

the thing is that. I have editet this module several times right, with that meaning that i have changed the value of $item 'path' several times. Before i had the path set to (admin/settings/favourite/quotes), and now it is (admin/settings/quotes), but the menu item quotes still links to (admin/settings/favourite/quotes),
even though i have pushed the cached button and even removed the module from the module directory, put it back again and once again enabled the module.

do you know why that is? sorry that this i hard to understand, im very new to this so having problems with expressing myself with all these new drupal stuff:P

grobemo’s picture

Aha. I have a guess about what's going on.

The "menu system" is not quite as the name suggests. It has always done much more than just control the menu, and it's not the only way to control the menu.

Did you ever create a menu item named "quotes" through the Administer > Site building > Menus screen? If so, you'll need to go back there and change the path there.

Go to Admin > Site building > Menus and look for a menu item called 'quotes'.

stinis87’s picture

aaaah, thanks:) it worked to remove them. but i noticed something. Im using drupal 6, and i noticed that it seems like hook_menu (drupal 5 version) has path as attribute, but drupal 6 has not? have i gotten this right? and how should i then assign a path to where the form should be shown?

grobemo’s picture

Yes, there are major changes to hook_menu between Drupal 5.x and Drupal 6.x. You should definitely read through the section on the menu system in D6 that I linked to in my first comment.

The menu system is, IMHO, one of the most confusing things when learning how to write modules. But once you get the hang of it, it's easy and powerful.

The short answer to your question is that the path is set in the keys of $items. Setting $items['admin/settings/favourite/quotes'] tells Drupal to show your form at yoursite.com/admin/settings/favourite/quotes.

stinis87’s picture

okay, i see:) it seems like it has come one step in the right direction now, because when i enter the path to the page in the browser, it now doestn show the (admin/settings) page anymore, but it says "access denied. You are not authorized to access this page." this is even worse isnt it?:P

grobemo’s picture

That's okay. You're making progress:

Take a quick look at this page on access control in Drupal 6.x to see how to format your access control settings.

stinis87’s picture

i'l do that:) thanks for all the help:)