Datafeedr Support Forums

Datafeedr Support Forums (
-   Tips, Tricks & Tutorials (
-   -   Multiple category and sub-category insertion (

seovisions November 21st, 2011 05:21 PM

Multiple category and sub-category insertion

I have discovered, quite by accident, that adding categories and sub-categories makes use of a delimiter for multiple entries:

PHP Code:


This is partially useful in that it shows that datafeedr allows for multiple insertion of category taxonomies. However, it loses it's usefulness because of what this particular delimiter actually does:

PHP Code:

Main Category
Main Category 
Main Category 
category1 category2
Main Category 
category1 category2 category3 

Which, essentially, nests each category followed by "/" into a sub-category of the one right before it. or:

PHP Code:


I've tried all the usual delimiter types to see if I could add several sub-categories under a main category in a single insertion. Such as

PHP Code:

/, |, \, :, `, ~, & 

of which only one has any result.

So my tip is the above, and my question is this:

Is there a delimiter in place to allow for multiple entries when adding categories and subcategories?

johnpo November 21st, 2011 06:55 PM

Yes the slash allows for one under one under and so on, unfortunately doesn't simply allow all one under so have to move them, but is still quicker than typing them all in.

Eric November 21st, 2011 08:53 PM


Originally Posted by seovisions (Post 26237)
Is there a delimiter in place to allow for multiple entries when adding categories and subcategories?

Not currently.

seovisions November 22nd, 2011 12:50 AM

perhaps you could add a delimiter. I am not entirely sure what you programmed everything in, nor how difficult it would be to add a delimiter.

Maybe a simple php explode on | would work along with a basic foreach with the SQL insert.

PHP Code:

$parent $_POST['parent'];
$add_category explode('|'$_POST['category_string']);

count($add_category) > 0){

//multiple entries to add
foreach($add_category as $value){
mysql_query("UPDATE table SET category = $value WHERE cat_parent = $parent );
echo 'Exception caught: ',  
$e->getMessage(), "\n";



//it's a single entry
UPDATE table SET category $value WHERE cat_parent $parent );
Exception $e){
'Exception caught: ',  $e->getMessage(), "\n";

You would, of course, fix it to fit the tables used, error checking, etc.

seovisions November 22nd, 2011 01:04 AM

preg_split() is another method to use if you want more control as well as preg_match_all().

Point is..lots of ways to do it. explode can be more memory intensive then the above two options.

All times are GMT -5. The time now is 10:29 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.