Ok so i was starting the planning of the release addon and i thought we need some way in a forum to find out what « level » it is (how many sub/parent forums with the same type are). i started writing some code for this and i realized it is not a simple thing but needs some discussion.
My idea is that while viewing a forum/thread you can get the forums level with the level being the number of parent forums with the same type above it plus 1 (i.e. if we had:
Forum 1 (Type: Blah; Level 1)
— Forum 2 (Type: Blah; Level 2)
—- Forum 3 (Type: Default; Level 1)
Forum 4 (Type: Blah; Level 1)
). This seemed good to me and then on say the release engine a forum with level X would have a template of X. But then i was thinking about more and i realized say that that would not work because we do not know the depth of that forum.
So what do you think the best approach would be?
Views: 27
you’Re actually resuming the goal of the only function you found in mtf_master_functions.php
😉
but i thought of it in a more basic level… category/sub-category:
we can always set a forum to act like a forum or not, when not it’s a category… same with the level depth.
i don’t think there’ll be a load of sub-situations… you can have a good idea of a parenting structure by visiting dmoz.org, here as example: Open Directory – Kids and Teens: Arts: Online Stories
how it works?
where you see « Pre-School », it’s a related forum, it’s a category within the main directory similar to the one we browse, but not related in content.
the other lines, are sub-categories, and the ones with @ are related subjects, not sub-forums… (i’ll release a addon soon that provide sub-related forums)
as you can see, the listing is simple, and have prefixes… (suffixes)
the example show you that even if you are in a sub-category, it’s complicated to go elsewhere without being a sub-category of something else.
as my engine was providing a way to modify the inheritence of a parent, i suppose we can use that technique and if someone ask for something more complex, we can rebuild the logic ?!
even if we have a 5 depth type, the only depth we check is the first and second levels… someone can design a third, depending on their choice… but organically, there is no difference with a second level.
am i logical?
Yeah, i think i’ll need to make a pretty extensive function to get the levels of the forum and make a cache of it that will allow flexibility later. i am going to make it get levels as deep as the admin made it and then the forum can say if (level > 2) level = 2; this way if we do ever make a type where we are gonna need that 3rd,4th, and maybe even 5th level it will be available to us.
Oh btw:
Here is my plan of how the code will work:
function mtf_get_levels($parentid = -1)
Gets forums with parent ids of $parentid
Then loop through those forums and get the sub forums.
Then we check to see if the forums match in type.
Then we call the function again and again getting the sub forums of ever forum and checking.
If the types do match up we add them to a global array ($GLOBALS)
Then finnaly after all the looping return the $GLOBALS
This function is then put in a CRON job and when you save a forum that way it is constantly updated and has a lower chance of getting corrupted.
yeah, i thought of the cronjob too, but basically, this caching is needed only when we edit a forum, isn’t it?
after setting your site for good, it’s nearly useless to have a cronjob, so maybe a single hit when we edit a forum would make it ?!
Yeah that makes sense…
Also i think i am going to add a table to the maintenance page to rebuild mtf cache that way in case something happens there is a way to do that
Ok after writing the function i know made it so it makes the opposite of what i said before. For example if we had:
Forum 1 (type: X
— Forum 2 (type: X
— — Forum 3 (type: X
Forum 1’s level would be 3 and forum 2 would be 2 etc.
To me it seemed more logical this way, what do you think?
i have no idea why it is more logical, but i follow you, do what you think is more efficient, we will break it all apart if nothing works.. lol
Well i think it’s more logical because say for example on the help desk addon. Level 1 would always show tickets and level 2 would show the categories.
Oh… yeah, i never thought of that depth… lol…
did i ever tell you that you’re brighter than me?!
I already know lol