6 years ago
3
Topic

Hello there

I am trying to delete content (article) programmatically.

I tried this example I got from other post without success (code simplified just to test):

    $id=1702;
    $content_to_delete = new JCckContent(array('joomla_article') );
    $content_to_delete->load($id);
    $content_to_delete->delete();

I have put this code in a form using all code pack fiels to test it.

Am I missing something?

Thanks in advance!

Get a VIP membership
4229 Posts
Kadministrator
6 years ago
2
Level 1

JCcck classes have changed, to you should use something like $content_to_delete = JCckContent::getInstance(array( 'joomla_article', $id )); to load your object.

6 years ago
1
Level 2

Tahnks Klas,

It worked 

To create  an article the code below is still valid?

   //CREATE
	$newStuff = new JCckContent( 
	    array('joomla_article') 
	);
	$addStuff = $newStuff->create(
	    'xxx',
	    array(
                // Joomla table ie #__content
	       // 'title'=> $fields['user_name']->value . '-' . $config['pk'],
	        'created_by'=> $config['pk'],
	        'state'=> 1,
	        'catid'=> 15,
	        'access'=> 1,
	        'language'=> '*'
	    ),
	    array(
             // Seblod table ie #__cck_store_form_xxx
	      'est_nome'=>$fields['user_name']->value,    
	      'est_usuario_id'=>$config['pk'],
	      'est_tipo'=>$fields['reg_profiletype']->value,
	      'est_origem_dados'=>'Usuário'    


                )
            ); //CREATE END
 
4229 Posts
Kadministrator
6 years ago
0
Level 3

Change is the same for all methods, you need to instantiate object as described above (except that you don't pass it an id as it is a new item).

Get a Book for SEBLOD