0

My database is like below enter image description here

Menu I'm willing to create is as below.

enter image description here

What I want to do is create a Joomla menu as shown above depending on the table rows in a table. If I add a row to the table, automatically menu item should be created.

EG: there are 3 rows in the sports table. So three menu are created as shown.

How can I do it? Given that I know how to retrive data from the database. I can get the list of sports and what I don't know is how to put then as a menu.

Techie
  • 44,706
  • 42
  • 157
  • 243

3 Answers3

1

Ok, remember that Joomla is a content management system so for things like content and menu items, it's all done through the admin backend.

So, in the admin backend, go to Menu Manager and select the menu you want to add items to. Then create a single menu item called "Sports", and set the type to "text separator". Then create you 3 sub menu items (Sports 1, Sports 2, Sports 3), set the type to whatever you wish, and set the parent to "Sports"

Hope this helps

Lodder
  • 19,758
  • 10
  • 59
  • 100
  • I want it to be done dynamically. I know how to create a menu item as you have said above. If I add a row to the table, automatically menu item should be created. – Techie Nov 20 '12 at 11:52
  • ok fair enough. can can you provide all the details of the database rows you have created and what current state it's in now. Is it working, working to a certain extent, or not at all? – Lodder Nov 20 '12 at 11:55
  • all I have is 3 rows. If I add a sport from the component of mine it will add a new row to the table. – Techie Nov 20 '12 at 12:09
  • yes, but as Bimal said, you need a column called "parent" which I dont seem to see in the screenshot of your table rows. Are you adding this data to a custom database table or the Joomla menu table? – Lodder Nov 20 '12 at 12:12
0

If you are going the dynamic way then this table might not be sufficient for your menu. You will have to add another column known as Parent which indicates id of parent term.

And you can use jQuery to automatically append data fetched from database to existing menu code on the fly or dynamically.

Bimal
  • 865
  • 10
  • 18
  • What if the user browsing the site has javascript turned off? I know it's stupid to do so but you never know ;) – Lodder Nov 20 '12 at 12:09
  • thanks for the answer but this is not an valid option as Lodder said. – Techie Nov 20 '12 at 12:10
  • There is an alternate solution. You can go php way and make a plugin for it or make changes to core files. Making changes to core files is not recommended for novice developers. – Bimal Nov 21 '12 at 06:33
0

n the Joomla framework, components are executed using menu items. If you go in the menu manager of your Joomla installation a HelloWorld menu item type does not yet exist. Adding this functionality is easy in Joomla. Simply put a site/views/helloworld/tmpl/default.xml file containing:

Read more

Techie
  • 44,706
  • 42
  • 157
  • 243