Export/Import cctag items

Created on 7 February 2012, almost 13 years ago
Updated 13 September 2024, 4 months ago

Currently there is no easy way to export and import settings for items.
The features module seems to be the best way atm.

I am trying to do this with an array and without getting the taxonomy tree I get an error in the admin form. To stop this can we change the isset to empty?

//line 130 of cctags.admin.inc
--   '#default_value' => (isset($item['item_data']['vocs']))?$item['item_data']['vocs'][$key]:FALSE,
++  '#default_value' => (empty($item['item_data']['vocs']))?$item['item_data']['vocs'][$key]:FALSE,

Then this should will work without errors.

function save_new_cctags_item ($settings) {
    $item       = array ();
    $block_name = array ();

    $page_path  = $settings[ 'page_path' ];
    $page_title = check_plain ( $settings[ 'page_title' ] );
    $fields     = array (
        'name'             => check_plain ( $settings[ 'name' ] ) ,
        'block'            => $settings[ 'block' ] ,
        'block_name'       => $settings['block_name'] ,
        'page'             => $settings[ 'page' ] ,
        'page_title'       => $page_title ,
        'page_path'        => $page_path ,
        'page_level'       => $settings[ 'page_level' ] ,
        'page_amount'      => $settings[ 'page_amount' ] ,
        'page_sort'        => $settings[ 'page_sort' ] ,
        'page_mode'        => $settings[ 'page_mode' ] ,
        'page_vocname'     => $settings[ 'page_vocname' ] ,
        'page_extra_class' => $settings[ 'page_extra_class' ] ,
        'item_data'        => serialize ( $settings['item_data'] ) ,
    );
    $cctid      = db_insert ( 'cctags' )->fields ( $fields )->execute ();
    if ( empty( $page_path ) && $settings[ 'page' ] ) {
        $page_path = 'cctags/page/' . $cctid;
        db_update ( 'cctags' )
            ->fields (
            array (
                'page_path' => $page_path ,
            )
        )
            ->condition ( 'cctid' , $cctid )
            ->execute ();
    }
    drupal_set_message ( t ( 'The Cctags item %name has been created.' , array ( '%name' => check_plain ( $settings[ 'name' ] ) ) ) );

    _cctags_clear_cache ( $cctid , 'all' );
    menu_rebuild();
    return $cctid;
}

$test = array (
    'cctid'            => 4 ,
    'name'             => 'tags' ,
    'block'            => 1 ,
    'block_name'       => 'Tags' ,
    'page'             => 0 ,
    'page_title'       => '' ,
    'page_path'        => '' ,
    'page_level'       => 5 ,
    'page_amount'      => 0 ,
    'page_sort'        => 'title,asc' ,
    'page_mode'        => 'mixed' ,
    'page_vocname'     => 0 ,
    'page_extra_class' => '' ,
    'item_data'        => array (
        'vocs'  => array (
//use your own vocab ids here with a 1 to enable
            3 => 1 ,
        ) ,
        'level' => array (
//use your own vocab ids levels here
            3 => array (
                0 => 1 ,
            ) ,
        ) ,
    ) ,
);

save_new_cctags_item ($test );

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia imp7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    I'm closing it because the issue was created a long time ago without any further steps.

    if you still need it then raise a new one.
    thanks

Production build 0.71.5 2024