Skip to main content
added 26 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
  // …
  'page arguments' => array(1),
);

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as(as already mentioned by LToomre,) you need to have:

'page arguments' => array(4),

but itIt is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array();

The named argument %epay_hash, is automatically mapped to a _load function:

function epay_hash_load($hash) {}

which takes the URL argument as paramterparameter, performs the DB queries necessary to load your object, and then returns it.

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
'page arguments' => array(1),

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as already mentioned by LToomre, you need to have

'page arguments' => array(4),

but it is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array(

The named argument %epay_hash, is automatically mapped to a _load function:

function epay_hash_load($hash) {

which takes the URL argument as paramter, performs the DB queries necessary to load your object, and then returns it.

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
  // …
  'page arguments' => array(1),
);

will pass on "structure" as an argument, not the %didyouknow id, nor a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so (as already mentioned by LToomre) you need to have:

'page arguments' => array(4),

It is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array();

The named argument %epay_hash, is automatically mapped to a _load function:

function epay_hash_load($hash) {}

which takes the URL argument as parameter, performs the DB queries necessary to load your object, and then returns it.

added 1 characters in body
Source Link
Letharion
  • 27.5k
  • 11
  • 83
  • 141

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
'page arguments' => array(1),

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as already mentioned by LToomre, you need to have

'page arguments' => array(4),

but it is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array(

The named argument %epay_hash, is automatically mapedmapped to a _load function:

function epay_hash_load($hash) {

which takes the URL argument as paramter, performs the DB queries necessary to load your object, and then returns it.

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
'page arguments' => array(1),

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as already mentioned by LToomre, you need to have

'page arguments' => array(4),

but it is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array(

The named argument %epay_hash, is automatically maped to a _load function:

function epay_hash_load($hash) {

which takes the URL argument as paramter, performs the DB queries necessary to load your object, and then returns it.

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
'page arguments' => array(1),

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as already mentioned by LToomre, you need to have

'page arguments' => array(4),

but it is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array(

The named argument %epay_hash, is automatically mapped to a _load function:

function epay_hash_load($hash) {

which takes the URL argument as paramter, performs the DB queries necessary to load your object, and then returns it.

Source Link
Letharion
  • 27.5k
  • 11
  • 83
  • 141

You have two problems in that code. First of all, you assume that having a didyouknow-id in the URL, is enough for Drupal to know where to get your object, the second problem is that your page argument is off.

This simplified code:

$items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
'page arguments' => array(1),

will pass on "structure" as an argument, not the %didyouknow id, nor not a didyouknow-object, which is why you get an error about a "non-object". Argument indexing start with 0 => admin, so as already mentioned by LToomre, you need to have

'page arguments' => array(4),

but it is also important to note that Drupal will not automatically know how to load your entity, you are required to provide the load function yourself.

As an example, look at the epay module, which has a menu hook like this:

$items['payment/epay/callback/%epay_hash'] = array(

The named argument %epay_hash, is automatically maped to a _load function:

function epay_hash_load($hash) {

which takes the URL argument as paramter, performs the DB queries necessary to load your object, and then returns it.