cali_dotcom Posted February 28, 2009 Share Posted February 28, 2009 hi, i'm creating the admin section for a multi-level category search/navigation system. i mean like, when a visitor comes to the site and they are looking for data, first a list of categories appears. for example ..... states....departments......etc. so when a user clicks on states, he gets another list of subcategories, and it can go on till he reaches the file/info he's looking for. i also wanted to make it multi dimensional so that a particular piece of information could be reached by different paths. on the admin side, i dont want to put a limit on the number of categories/levels an administrator can put in. Now my problem is figuring out the logic necessary to sort and store the data when the administrator uploads them so that in the front end, it would be easy for visitors to find them. i was thinking of prompting the admin to sort the contents during upload into different categories. then i could store those id's along with the contents in the database. still figuring how i would go about that though. does anyone have any ideas how i can go about this? Quote Link to comment https://forums.phpfreaks.com/topic/147244-creating-a-multi-level-category-searchnavigation-system/ Share on other sites More sharing options...
RussellReal Posted February 28, 2009 Share Posted February 28, 2009 make a menu table use serialize to group values together.. in pairs OPTION -> VALUE $opt = serialize(array("option","value")); then store that into a db with all the other option serialisations seperated by \x01 or something unconventional then when you're going to place the next level in call that menu from the db and unserialize all the options and then place the options where they belong.. then you just need a menu table instead of a hundred text files for each menu.. and its easier to work with in terms of coding the admin panel Quote Link to comment https://forums.phpfreaks.com/topic/147244-creating-a-multi-level-category-searchnavigation-system/#findComment-773042 Share on other sites More sharing options...
cali_dotcom Posted February 28, 2009 Author Share Posted February 28, 2009 i dont think i understand what you are saying. so, to group the category id's and serialize them? what would be the logic for the search for the front end? i'm trying to make it possible to reach a resource through multiple paths. do you have any example i could look at? Quote Link to comment https://forums.phpfreaks.com/topic/147244-creating-a-multi-level-category-searchnavigation-system/#findComment-773064 Share on other sites More sharing options...
RussellReal Posted February 28, 2009 Share Posted February 28, 2009 ok for example: you have a table `menu_table` now.. the construct on this table is: int `id` auto_increment text `page` text `options` a fake entry of this table: `id` = 1 `page` = index.php `options` = a:3:{i:0;a:2:{i:0;s:4:"HOME";i:1;s:9:"index.php";}i:1;a:2:{i:0;s:8:"SERVICES";i:1;s:12:"servives.php";}i:2;a:2:{i:0;s:9:"DOWNLOADS";i:1;s:13:"downloads.php";}} how we arrived at the options to look that way is rather simple to manage: <?php $arr = array(); $arr[] = array("HOME","index.php"); $arr[] = array("SERVICES","services.php"); $arr[] = array("DOWNLOADS","downloads.php"); $options = serialize($arr); ?> to undo the serialization is simple.. <?php //do your mysql stuff here and read from the table for the current page $arr = unserialize($row['options']); $arr[] = array("PAGE TO ADD","PATH/TO/PAGE.php"); $options = serialize($arr); I'm sure you could bridge something off of this to simplify the means of building menues for each of your pages Quote Link to comment https://forums.phpfreaks.com/topic/147244-creating-a-multi-level-category-searchnavigation-system/#findComment-773119 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.