banana7777 VIP
Total posts: 18
24 Mar 2015 21:07

Hi,

I want to import the Field "URL" but in the Import I don't see this field to import. I'm using URL V8.61.

Thanks for your help.

Best, Dirk

Last Modified: 07 Apr 2015


banana7777 VIP
Total posts: 18
28 Mar 2015 10:52

Hi,

solved the problem by adding this to url.php.

public function onImport($value, $params, $record = null)
{
    return array(
            0 => array (
                'url' => $value
        )
    );
}    

public function onImportForm($heads, $defaults)
{
    return $this->_import_fieldlist($heads, $defaults->get('field.' . $this->id));
}

Sergey
Total posts: 13,748
30 Mar 2015 09:12

Perfect! I added this to the next version.


banana7777 VIP
Total posts: 18
30 Mar 2015 10:58

Hi Sergey,

I will add labels import this night and share the code again.

Thanks and best, Dirk


banana7777 VIP
Total posts: 18
30 Mar 2015 21:55

I changed the code for importing labels.

public function onImport($value, $params, $record = null)
{
    return $value;
}

public function onImportData($row, $params)
{
    $return = [];
    if ($row->get($params->get('field.' . $this->id.'.url')))
    {
        $return[0]['url'] = $row->get($params->get('field.' . $this->id.'.url'));
        if ($row->get($params->get('field.' . $this->id.'.label')))
        {
            $return[0]['label'] = $row->get($params->get('field.' . $this->id.'.label'));
        }
    }
    return $return;
}

public function onImportForm($heads, $defaults)
{
    $pattern = '<div><small>%s</small></div>%s';

    $out = sprintf($pattern, JText::_('Label'), $this->_import_fieldlist($heads, $defaults->get('field.' . $this->id . '.label'), 'label'));
    $out .= sprintf($pattern, JText::_('URL'), $this->_import_fieldlist($heads, $defaults->get('field.' . $this->id . '.url'), 'url'));

    return $out;
}

Is there a way while importing to delete the data out of the database?

Thanks and best, Dirk


Sergey
Total posts: 13,748
07 Apr 2015 12:04

Ok. Added.

banana7777 Is there a way while importing to delete the data out of the database?

The import is designed to append data. This means next time you import the same list it will update articles rather than create new. I think if in new CSV field will be empty, value will be deleted. But I am not sure and hard to test now.


banana7777 VIP
Total posts: 18
07 Apr 2015 16:18

Ok. Thanks for the information. I will check it and reply. Not sure if this is true for all fields. What I remember is that a text field will not be deleted the next time if I update the field to an empty value. Anyhow, I will check and give feedback.

Best, Dirk

Powered by Cobalt