2

I have a link "Add Details". suppose when I click on the Add Details, I will send arguments to the urls. such as in url "http://localhost/drupal/video" video will be my argument. When I click on "Add Details" link if argument is video then I want to go to "Video content type".

When I click on "Add Details", if argument passed is "image" in url("https://localhost/drupal/image), Then I want to go to "image content type".

When I click on "Add Details" link depending on the argument passed in URL I want to go to specific Content type.

How to achieve this.

Any help is appreciated.

1

Use hook_menu in custom module to achieve this using below code !
Change the links of Add Details to "goto/video" means full url will be localhost/drupal/goto/video

function yourmodule_menu() {
    $menus['goto/%'] = array(
        'title' => 'Just Redirect',
        'page callback' => 'drupal_redirect_to_content_type',
        'page arguments' => array(1),
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );
    return $menus;
}

function drupal_redirect_to_content_type($type) {
  drupal_goto("admin/structure/types/manage/" . $type);
}

Otherwise,

Instead of above what you can do it directly give Add Details link to admin/structure/types/manage/ . $type instead of drupal/$type

  • Is there anything wrong with the code:function drupal_redirect_to_content_type($type) { if($type == 'videolibrary'){ drupal_goto("drupal/node/add/exhibit"); } else{ drupal_goto("drupal/node/add/section"); } } When I click on the "Add Section Details" which is hyper linked to "localhost/drupal/videolibrary" Getting page not found error. sorry If anything is wrong with my coding. – Cindrella Oct 5 '12 at 9:45
  • remove drupal , make it "node/add/exhibit" if you are in localhost then localhost/drupal will become your base path ! – Anil Sagar Oct 5 '12 at 9:47
  • Same page not found error is occuring with the url showing "localhost/drupal/videolibrary" – Cindrella Oct 5 '12 at 9:48
  • 1
    See my updated answer ! Change the links of Add Details to "goto/video" means full url will be localhost/drupal/goto/video Clear menu cache after doing changes ! – Anil Sagar Oct 5 '12 at 9:49
  • Did all the things mentioned . But still getting the same page not found error. Am I missing anything? – Cindrella Oct 5 '12 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.