Member Avatar

Hi, I have created a function that searches for a category in a category tree object and returns all the paths for it as an array of strings, please advice how I can improve it ? the result im getting now is : ["vehicles",["cars","mercedes"],["trucks","mercedes"],["motorcycles","BMW"]] i need it in one dimesional array like this : ["vehicles","cars","mercedes","trucks","mercedes","motorcycles","BMW"] here is also a plunker url for the same code im trying t solve : [Click Here](http://plnkr.co/edit/JOH63BuL55HgEtEYnVjd?p=preview) thanks in advance, please advice. var categories = {category:"vehicles",children:[ {category:"cars",children:[{category:"mercedes",children:[]}]}, {category:"trucks",children:[{category:"mercedes",children:[]}]}, {category:"motorcycles",children:[{category:"BMW",children:[]}]} ]}; function getnodes(nodes) { var arr=[]; if (!nodes.children.length) return nodes.category; else{ arr.push(nodes.category); for(var i =0 ; …

Member Avatar
+0 forum 1
Member Avatar

Hi, I'm developing a blog that will have categories. I want to be able to store blog posts in more than one category. My problem is i am not sure how to go about it. I have a table called posts: CREATE TABLE `posts` ( `post_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_uid` int(10) unsigned NOT NULL COMMENT 'user uid', `category_ids` varchar(255) NOT NULL COMMENT 'each category is seperated by a comma', `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'date post was modified', `post_status` varchar(10) NOT NULL COMMENT 'publish = publish post | …

Member Avatar
+0 forum 2

The End.