Skip to main content
added 196 characters in body
Source Link

I have a problem concerning a landing page and 404 errors.

Context : I have a content type "news", with auto url /news/my-news-title. I have created programmatically a kind of homepage for news, with /news as URL

What's wrong : My problem is that if I have a link like /news/aiejaziejfnjdfnj (it doesn't exist), I don't have a 404 error and this is my /news landing page which is shown. What I wish, with you help, is to have a 404 error when I have a non existant URL.

I'm going to show you what I have done, and hope sincerely you'll have an idea of what i'm doing wrong. In a custom module, I have :

function mymodule_menu(){
    $items = array();
    $items['news'] = array(
       'title' => "Les news",
       'page callback' => 'landing_page',
       'access arguments' => array('access content'),
    );
    return $items;
}
function landing_page(){
    return "nothing";
}

Then, I have a template page--news.tpl.php in which I have write things manually without showing $content (the "nothing").

So, why /news/aizejziej is accepted and is showing /news ? Is it function landing_page() which is doing something bad by always returning something ?

Thanks in advance for your help/ideas :)

Edit : Is it possible to create a node with /news as alias, and then theme it with page--node--[node-id].tpl.php (or kind of) ? I'll didn't have my bad hook_menu and landing_page thing...

I have a problem concerning a landing page and 404 errors.

Context : I have a content type "news", with auto url /news/my-news-title. I have created programmatically a kind of homepage for news, with /news as URL

What's wrong : My problem is that if I have a link like /news/aiejaziejfnjdfnj (it doesn't exist), I don't have a 404 error and this is my /news landing page which is shown. What I wish, with you help, is to have a 404 error when I have a non existant URL.

I'm going to show you what I have done, and hope sincerely you'll have an idea of what i'm doing wrong. In a custom module, I have :

function mymodule_menu(){
    $items = array();
    $items['news'] = array(
       'title' => "Les news",
       'page callback' => 'landing_page',
       'access arguments' => array('access content'),
    );
    return $items;
}
function landing_page(){
    return "nothing";
}

Then, I have a template page--news.tpl.php in which I have write things manually without showing $content (the "nothing").

So, why /news/aizejziej is accepted and is showing /news ? Is it function landing_page() which is doing something bad by always returning something ?

Thanks in advance for your help/ideas :)

I have a problem concerning a landing page and 404 errors.

Context : I have a content type "news", with auto url /news/my-news-title. I have created programmatically a kind of homepage for news, with /news as URL

What's wrong : My problem is that if I have a link like /news/aiejaziejfnjdfnj (it doesn't exist), I don't have a 404 error and this is my /news landing page which is shown. What I wish, with you help, is to have a 404 error when I have a non existant URL.

I'm going to show you what I have done, and hope sincerely you'll have an idea of what i'm doing wrong. In a custom module, I have :

function mymodule_menu(){
    $items = array();
    $items['news'] = array(
       'title' => "Les news",
       'page callback' => 'landing_page',
       'access arguments' => array('access content'),
    );
    return $items;
}
function landing_page(){
    return "nothing";
}

Then, I have a template page--news.tpl.php in which I have write things manually without showing $content (the "nothing").

So, why /news/aizejziej is accepted and is showing /news ? Is it function landing_page() which is doing something bad by always returning something ?

Thanks in advance for your help/ideas :)

Edit : Is it possible to create a node with /news as alias, and then theme it with page--node--[node-id].tpl.php (or kind of) ? I'll didn't have my bad hook_menu and landing_page thing...

Source Link

Landing page extension without 404 error

I have a problem concerning a landing page and 404 errors.

Context : I have a content type "news", with auto url /news/my-news-title. I have created programmatically a kind of homepage for news, with /news as URL

What's wrong : My problem is that if I have a link like /news/aiejaziejfnjdfnj (it doesn't exist), I don't have a 404 error and this is my /news landing page which is shown. What I wish, with you help, is to have a 404 error when I have a non existant URL.

I'm going to show you what I have done, and hope sincerely you'll have an idea of what i'm doing wrong. In a custom module, I have :

function mymodule_menu(){
    $items = array();
    $items['news'] = array(
       'title' => "Les news",
       'page callback' => 'landing_page',
       'access arguments' => array('access content'),
    );
    return $items;
}
function landing_page(){
    return "nothing";
}

Then, I have a template page--news.tpl.php in which I have write things manually without showing $content (the "nothing").

So, why /news/aizejziej is accepted and is showing /news ? Is it function landing_page() which is doing something bad by always returning something ?

Thanks in advance for your help/ideas :)