Welcome Guest, Not a member yet? Register   Sign In
category -> subcategory ->subsubcategory system
#1

[eluser]kmunky[/eluser]
hi there!
first of all i have to mention that i'm quite new to CI. So...i was wondering how can i programatically do a dynamic hierarchical system? you know what i mean.. my url should look something like
Code:
http://mysite.com/category/subcategory/subsubcategory/etc..
and the user can add more and more categories and subcategories to expand the tree.
hope you can help me. thanks :-)
#2

[eluser]jedd[/eluser]
Hi kmunky and welcome to the CI forums.

This question pops up quite regularly, so you might want to spend some time trawling the forums for previous threads (try topic searches that include hierarchy, recursive, subcategories, subcategory, sub-category, etc).

[quote author="kmunky" date="1266141505"]
... a dynamic hierarchical system?
[/quote]

There's obviously several aspects to this - parsing your URL (fairly simple), doing something with that URL (less so), and persumably having some data in a database somewhere that you're working with (least simple).

What bits have you a) done, and/or b) got your head around so far?
#3

[eluser]kmunky[/eluser]
thanks @jedd for your reply. I didn't check on forum yet but i was thinking on something, to create a base controller and the first section of the url be it's name; the argument for that controller to be the last section of the url. now...my questions are:
1. do you think that the implementation of this system will be possible, will it be reliable?
2. how can i generate the url? i'm thinking of using mysql nested set model or it's doctrine equivalent (i'm not quite sure how it works but i'll focus on it), or is there a better way to do this without database interrogation ?

many thanks
#4

[eluser]jedd[/eluser]
Have a read of [url="/forums/viewthread/137031/"]this thread[/url].

Summary - you don't need all the parent categories to be present in the URL in order to identify the given sub(sub...)category. Or, if you prefer, the item's location in the hierarchy.

EDIT: - scratch that earlier thread reference - I went hunting for a recent thread that was similar to this one. I can't find the actual thread, and annoyingly can't remember who I was talking to about it, but the summary stands (which kind of answers your two questions, too Smile
#5

[eluser]kmunky[/eluser]
[quote author="jedd" date="1266182264"]you don't need all the parent categories to be present in the URL in order to identify the given sub(sub...)category.[/quote]

ok...i know i don't need them but...i want them Smile this way the url becomes more SEO friendly, doesn't it?or am i wrong? thanks
#6

[eluser]jedd[/eluser]
[quote author="kmunky" date="1266183673"]
ok...i know i don't need them but...i want them Smile this way the url becomes more SEO friendly, doesn't it?or am i wrong? thanks[/quote]

I don't know. SEO stuff leaves me cold. Others around here are better informed and may weigh in on the subject.


There appears to be a couple of problems with showing all parents in the URL - though how much this affects you is obviously your call.
o Hugely long and ugly URLs (1)
o If you move branches or children around in the hierarchy, extant URLs to those children are now stale - or worse (for SEO, AFAIK, duplicates)
o If a child can have multiple parents you'll end up with multiple URL's pointing to identical data (as intimated in the previous, I believe this is ungood)

(1) or you pick an arbitrary point at which you stop displaying generations and just determine location by the last segment - then it's a matter of degree (and I tend to think a degree of '1' is ideal Smile




Theme © iAndrew 2016 - Forum software by © MyBB