I've tried the simplest examples of using hook_menu() posted here and on other Drupal forms and noting seems to work. My code, in: /sites/themes/mytheme/mymodule.module, is as follows:
<?php
function helloworld_menu() {
$items = array();
$items['hello'] = array(
'title' => 'Hello world!',
'type' => MENU_CALLBACK,
'page callback' => 'helloworld_page',
'access callback' => TRUE,
);
return $items;
}
function helloworld_page() {
return 'Hello world !';
}
When I navigate to www.mydomain.com/hello I get a 404 error. I've tried enabling and disabling the module along with clearing the cache numerous times with no luck still. Here is some additional information about my environment:
- Running Drupal Commerce version 7.22
- I've enabled clean URLS and pathauto module
The end goal I'm trying to achieve is adding products to the cart with a link. I already have that part working so that I can pass product ID's into a function and add them to cart. I would be replacing helloworld_page() with my function and then changing $items['hello'] to $items['cart/add/%/%'], having two wildcards (product ID and quantity).