1

I created a custom content type (pics). I can add this new "pics" content to my site (and if I want to, it can appear on front page, but I don't want to...) with no problem. But I would like those new added contents appear in my new menu (called Photos).

When I created my new content type I got a " machine name" : "pics". Then I created a new menu called "photos" and I put this name into the path field like this: http://www.example.com/drupal/pics

But it doesn't work this way. The menu will be empty with a Page not found message.

I'm new to drupal, so please bare with me. Please let me know the solution.

  • you don't need to say thank you in a question, or use a signature (-Sam). How did you create the menu? is it a regular menu? a Views menu? a custom hook_menu() page? something else? we need more information please – Geoff Jun 12 '15 at 20:33
  • Structure/Menus/Main Menu/Add link – sam Jun 13 '15 at 0:22
  • I'm not sure what to put at the "path" section (of my menu called Photos) to be able to put every node created by add content type /pics).I want any user of the site to be able to use this add content type/pics feature and I want all these contents go under my created menu: Photos. This way you can see together under 1 menu all the contents that users created... – sam Jun 13 '15 at 0:32
  • so you want a separate menu listing for each user? or a single menu with ALL of the content? either one is a bad idea and will overload the menu system, slowing the site down considerably as content continues to be created – Geoff Jun 13 '15 at 0:33
  • I wanted a single menu for all contents that were created by clicking on add content/pics. So all the "pics" contents will be under the menu "Photos". I understand what you are saying with system overload, but at least theoretically it would be good to know how to achieve this type of organization. – sam Jun 13 '15 at 0:55
1

By default, Drupal 7 does not create a filtered list of content. You're going to want to use Views Page to create a list of content.

Delete the menu item you created, then install https://www.drupal.org/project/views and its dependency https://www.drupal.org/project/ctools

If you have Drush installed...

drush dl views drush -y en views views_ui

  • In your browser, go to /admin/structure/views
  • Click "Add new view".
    • View Name: Photos
    • Show [Content] of type [Pics]
    • [X] Create a page
      • Page title: Photos
      • Path: pics
      • Display format: Table
    • Click "Continue & edit" to customize

For information on Views, see https://www.drupal.org/documentation/modules/views

  • 1
    Thanks everyone! jonpeck "view" solution works for me the best. – sam Jun 13 '15 at 2:29
  • Yes, that was the best answer to my question. The view helped a lot to achieve what I wanted. – sam Jun 16 '15 at 16:54
0

Getting around the error message:

You're getting that error like 'Page not found message', because when creating a menu item like you tried to do, Drupal expects the path that you enter to exist. If however you would specify node/xyz (with xzy = actual node ID of the node you want the menu item to point to), then Drupal would find that path, and you should not get such error message.

Possible alternative:

Create a new node, or edit an existing one, and specify these values while in the edit form of that node:

  1. the path you want the node to use (= 'drupal/pics' in your case).
  2. the menu item you want to be created for it (within menu 'photos').

After saving such node, you should get the desired result also.

Curious to hear if either of both approaches answer your question ...

0

based on your comments, this works - this code assumes a content type Article, adjust as necessary:

  • create a parent menu item within the main menu (PICS), set Show as Expanded TRUE, set the Parent to Main Menu

enter image description here

  • in the content type set up, set the Menu Settings to Main Menu, with PICS as the parent

enter image description here

  • There are modules that will do this, but if all you need is a simple menu entry override, you can use this custom module:

custom_menu_entry.info

name = Custom Menu Entry
core = 7.x
description = Automatically Creates an Entry on Node Save
package = custom

custom_menu_entry.module

<?php
/**
*   Custom Menu Entry Module - Force a menu entry to be created on node save
**/
function custom_menu_entry_node_insert($node)
{
    if($node->type == 'article')
    {
        $node->menu['enabled'] = true;
        $node->menu['link_title'] = $node->title;
    }
} 

This will force the menu entry to be created on node save, but again it is unwise in your particular use case - A view is a more suitable option.

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.