Closed (won't fix)
Project:
Feeds
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Jun 2012 at 20:14 UTC
Updated:
26 Feb 2017 at 20:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nlambert commentedthe patch
Comment #2
pindaman commentedHI,
How does it work
I have a field i want to use as menu item.
eg. menu main-menu
parent-item:apples
child item: green
is it meant for such solution?
Without doc i am a bit lost :(
pinda
Comment #3
nlambert commentedYou must map your csv column to the "Menu Name" mapper in your feeds importer. The column must contain only the system menu name. As it is, there are no options to select the parent item. However, I've been reading the feeds issue queue: there is an effort to make feeds more language aware when translating fields. The above patch wouldn't work in that situation. I'm waiting to see how things progress before updating the patch.
Cheers
Comment #4
pindaman commentedso my csv should look like:
"menu-name";"menu-item";"child-item";
"menumain-menu";"apples";"green";
??
sorry for the questions.
I have been playing around with feeds now for over a week..
I am getting a bit crazy now.
Comment #5
nlambert commentedThe mapped field (only one field) should only contain the system menu name. The name/title of the menu item will be created automatically based on the node title. The node title field should therefore be mapped before the "Menu Name" field.
We had many nodes to import and many needed a menu item in various different menus. The patch was pratical for that, but does not allow for menu hierarchy.
Another consideration when using the patch is that the menu item title cannot differ from the node's title.
The last consideration, I believe, is language. When translating the full node this isn't a problem, but when translating using field translation I don't believe this is possible (but I could be mistaken).
Hope this helps.
Comment #6
pindaman commentedThanks for clearing all out to me
as menu items need to be different than the node titles this is not useable for my current project.
But I can image it being usefull in other projects.
Thanks for you quick replies.
regards,
Pinda
Comment #7
sutharsan commentedThe added functionality is minimal, but is a good starting point. Only a few code style fixes to do.
Trailing white space in various places.
Comment #8
sutharsan commentedRerolled the patch for latest dev release. Added (empty) menu description property.
Comment #9
nlambert commentedDefinately basic functionality indeed. In order to add more functionality there should be a different mapper for each menu composant (menu name mapper, menu title mapper, menu parent mapper, etc...).
@Sutharsan: What do you think?
Comment #10
sutharsan commentedYes, very basic (I code my way around the basics). Agree, there should be facilities to import all the other properties of a menu item too.
Re . "Parent link" One field in the imported data set was a unique identified "ID". My "Parent" import field contained the value of an "ID" field. The "ID" value precedes the "Parent" value in the import data, e.g. ID = 'foo5' is in row 5, Parent = 'foo5' is used in row 6, 7 or further.
Comment #11
skriptble commentedThis is working great for me. I was just wondering when there would be a commit for it, at least in the dev branch?
Comment #12
crutch commentedThis is not working well for me with Alpha-8 and the patch above importing an XML feed using Xpath for mapping. So since I only really need them in the menu system for accurate breadcrumbs, I use https://drupal.org/project/crumbs
Comment #13
attisanjust in case someone needs a more sophisticated version, I have set up a sandbox with more options.
https://drupal.org/sandbox/attisan/2144379
feel free to comment and request.
greets
Comment #14
crutch commentedI would like use menu in feeds but at this time ended up using Views & Views Accordion to create a Menu Block for left margin for specific sets of content. It works for this case because only showing 2 levels deep in primary menu. Views Accordion may not be required but didn't try without.
Create new View Block, add Content: Type in filter criteria, add Content: Type and Content: Title in fields.
Format: Views Accordion
Settings
Group: Content: Type
Use rendered output to group rows = true
Allow all rows to be closed = true
Use group header as accordion header = true
Animation: Slide
Event: Click
Autoheight = false
Clearstyle = true
Sort Criteria
Will have to locate a field that will sort it like you want
Content Type Names
Had to alter the content type names to get the parent menu item names correct
Style to taste
Comment #15
twistor commentedSorry to be a buzzkill.
This seems simple at first. But, it's going to spiral into mapping to menu by GUIG, URL. Mapping the menu parent, and who knows what else.
This is all possible from a contrib module.
Comment #16
hjvfy commentedit's not working
First I used last release of feeds, then I specially dowloaded and try to use 7.x-2.0-alpha8+71-dev version, but no result.
in mapping page I see :
item "Menu name (menu_name) The system name of the menu in which to add a link. The menu must be enabled in the content type".
but after importing against my menu title is the same name of menu, which is in title of node
Comment #17
medwassim commentedwe need feeds module to import nodes. in nodes content type we define the menu parent.
in my case the simple way is hook_node_insert or hook_node_presave like this :
/**
* Implements hook_node_insert().
*/
function MY_MODULE_node_insert($node){
if($node->type == 'MY_CONTENT_TYPE'){
$menu = variable_get('menu_parent_' . $node->type, 'main-menu:0');
$menu = explode(':', $menu);
if($menu[0] == 'main-menu' && $menu[1] != 0) { //main menu && not in first level
$node->menu['link_title'] = $node->title;
$node->menu['link_path'] = 'node/' . $node->nid;
$node->menu['menu_name'] = 'main-menu';
$node->menu['module'] = 'menu';
$node->menu['plid'] = $menu[1];
$node->menu['customized'] = 1;
$node->menu['enabled'] = 1;
//$node->menu['hidden'] = 1; //disable the menu link
$node->path['pathauto'] = 1;
}
}
}
nodes are attached to menu and alias is generated correctly.
Comment #18
portulaca+1
Comment #19
xaqrox+1 for attisan's sandbox project, worked really well for me. https://www.drupal.org/sandbox/attisan/2144379
Comment #20
pierre-nono commentedAttisan's sandbox is exactly what I needed for a important project !
Thanks you very much !
I still got these two errors, but there are just warning and notice :
Warning: Illegal offset type in isset or empty in menu_cache_clear() (line 2690 of C:\xampp\htdocs\Feeds\includes\menu.inc).
Notice: Array to string conversion in menu_cache_clear() (line 2691 of C:\xampp\htdocs\Feeds\includes\menu.inc).
And I can't seem to make it work for the main menu, but it's probably my fault.
And , just for info another close solution is this sandbox project:
https://www.drupal.org/sandbox/darth-romios/2639162