2

In my current active menu item, I want to get the next possible (enabled) menu item. Is there any coherent approach to do so?

Update: Case: I have a menu named English Menu It has five items.

I am currently in item 1, and naturally the next item would be item 2. With such strategy in mind, I can create a nice navigational menu for pages (apart from main navigation) like this:

Next Page (Item 2)

  • Can you elaborate a bit more of what you are trying to achieve? Put some more context in your question. – FFrewin May 12 '16 at 16:19
  • @FFrewin updated – Mostafa Talebi May 12 '16 at 17:08
  • Hi. It's very hard to understand you question. You are talking about a <ul> menu, sub menu or what?Do you want to target menu items with CSS? – Mike Fitzpatrick May 12 '16 at 18:17
  • @Mike Fitzpatrick, Please don't confuse client and server. I'm talking about Menu Records saved in the database. Forget about client side. I just gave the client example to clarify things further, which nevertheless, has resulted the otherwise. – Mostafa Talebi May 13 '16 at 8:28
  • Still not sure I get the question - do you simply want a next article / previous article on each page so users can go back and forward? – Mike Fitzpatrick May 13 '16 at 9:41
2

You could get the next item using the lft and rgt fields simply by getting the first item with a higher lft value than your current item's rgt value, and only selecting published items.

SELECT *
FROM #_menu
WHERE menutype LIKE 'your_menu'
AND published = 1
AND lft > [current item rgt]
ORDER BY lft ASC
LIMIT 1

Depending on if you want to include items from other levels of your menu you might want to add an "AND level = [your current item's level]".

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.