CodeIgniter Forums
Pages, Categories and Subcategories - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Pages, Categories and Subcategories (/thread-18189.html)

Pages: 1 2


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]yannyannyann[/eluser]
Hi,

I don't know if it's the right place to ask for this, but I am thinking about my problem, and I can't reach the end of it ...

I wanna build a navigation menu of 3 levels, like this :

Code:
HOME
ABOUT US
|_ WELCOME
|_ CONTACT
R&D Services
|_ R&D Areas
|  |_ Area 1
|  |_ Area 2
|  |_ Area 3
|_ R&D labs


As you see I want to have as pages : HOME, WELCOME, CONTACT, Area 1, Area 2, Area 3 and RD Labs.

The others are just categories (About US, RD Services, RD Areas)


So in my DB I have:

- a Pages table, with categoryID
- and a category table, with parentCategoryID



My problem: how do I do to create dynamiccally the menu, knowing that element displayed on the same level are either Categories or Pages ?


Is there a basic exemple somewhere to do that ?


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]jdfwarrior[/eluser]
this could be done several ways. One would be to just dump all of them in a single table and then just have an extra field that would relate the entry to a parent. It could still be done with multiple tables too, just depends on how you want to do it. To pull it all together, in the view, select the objects that dont have a parent, then for each one of those, select all the ones that list it as its parents, and so on.


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]Dam1an[/eluser]
Will the pages only evr appear under a single category, or could certain pages appear under multiple categories?


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]yannyannyann[/eluser]
thanks for your answers,

a page only in one category


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]jdfwarrior[/eluser]
just dont use popups


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]OES[/eluser]
I would suggest creating a Hierarchical menu system.

You can see 2 good examples here.

http://www.sitepoint.com/article/hierarchical-data-database/2/

http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

If you go that way if you PM me ill send you some code so you can create the menu.

good Luck

[OES]


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]bgreene[/eluser]
Hiya,
I'm only new to php but I have a similar menu (see ecoland.com) and I use only one table with structure |id|parentid|title|otherfields|. To build the menu, i just pull all data out of the table and call a basic recursive function in php. Don't know whether its good or bad but it works.


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]slowgary[/eluser]
@jdf

You've been bashing the miracle of popups all over this forum and it's unacceptable. Popups are a wonderful and legitimate way to present data to the user and I don't take kindly to your hatred towards them. If every site used nothing but popups, they wouldn't be called popups, they would just be "the way". So maybe instead of being so closed minded about popups (and popunders), one of these days you could just pop in and pop out a few popups before you get popped. Understand?


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]jdfwarrior[/eluser]
[quote author="slowgary" date="1240979891"]@jdf

You've been bashing the miracle of popups all over this forum and it's unacceptable. Popups are a wonderful and legitimate way to present data to the user and I don't take kindly to your hatred towards them. If every site used nothing but popups, they wouldn't be called popups, they would just be "the way". So maybe instead of being so closed minded about popups (and popunders), one of these days you could just pop in and pop out a few popups before you get popped. Understand?[/quote]

Wow thanks mom, I'm glad you enlightened me. Now let me educate you for a moment. My comments are what is more commonly known as a 'joke'. Dam1an was talking in the other thread joking about the popups as well, he commented here so I made a remark. Don't get your panties in a bunch. It's ok. I promise.


Pages, Categories and Subcategories - El Forum - 04-28-2009

[eluser]jdfwarrior[/eluser]
[quote author="slowgary" date="1240979891"]@jdf

You've been bashing the miracle of popups all over this forum and it's unacceptable. Popups are a wonderful and legitimate way to present data to the user and I don't take kindly to your hatred towards them. If every site used nothing but popups, they wouldn't be called popups, they would just be "the way". So maybe instead of being so closed minded about popups (and popunders), one of these days you could just pop in and pop out a few popups before you get popped. Understand?[/quote]

Also, since you want to be preachy to me, I was the first person to respond to his question and give him an answer. All you've contributed to this thread is whining about what I'm doing. If I'm answering questions, and your not, what do you REALLY have to whine to me about.