Creating your own import type

DataGrab has the ability to import other kinds of data than default types that it comes bundled with (CSV, JSON, Wordpress, and XML).

To add a custom data type add add the folder "datagrab_datatypes" in the addons directory at the same level as your "datagrab" add-on folder. For example:

If you create a file with the same name as an existing file in the datagrab/datatypes directory, it will be loaded first, effectively giving you the ability to override core DataGrab functionality. With great power comes great responsibility. While we provide the ability to do this, we do not offer support for debugging or assisting creating these override files. You're on your own should you choose this path.

Your datatype class will need to extend the AbstractDataType class. At minimum it will need to implement the fetch() and next() methods.

<?php

class Datagrab_twitter extends AbstractDataType
{
    public function fetch()
    {
    }

    public function next()
    {
    }
}

Now when you go to the DataGrab module you should have an extra option in the “Create new import” menu.

Last updated