I need to create a link to first submenu item from specific menu. The link will be placed in custom block.
To be more precise, I have a menu with following structure:
parent-menu item-1 item-2 item-3 ..
I need that after clicking "parent-menu" user would end up in item-1 page. Also, there will be several links in some blocks, linking to "parent-menu" - they need to open 'item-1' item too.
My current approach is to create 'parent-menu' page template override which finds top child item from 'parent-menu'. That page will be linked from content and main menu. Problem is that I need a way to find first menu sub item from code.
Ended up on using query:
$link_path = db_select('menu_links', 'n') ->fields('n', array('link_path')) ->condition('n.plid', '269', '=') ->orderBy('weight', 'ASC') ->range(0, 1) ->execute() ->fetchField();
Is there any alternative way to do this, without querying database?