Posted by abissbo on November 16, 2012 at 9:35am
Hi,
I have a taxonomy vocabulary named "jenis dokumen". I want to let anonymous users add terms within this vocabulary. I'm trying to add a block and render that form to add new term using PHP filter, but it's failing.
This is my code:
<?php
include_once(drupal_get_path('module','taxonomy') . '/taxonomy.admin.inc' );
return drupal_render(taxonomy_form_term('jenis_dokumen' . /'add'));
?>Can anyone help, please...
Comments
Well you can create a custom
Well you can create a custom module to display to taxonomy form to add term into it, below is code developed for Drupal 6, can modify for drupal 7 by following its api's:
<?php
function MYMODULENAME_menu()
{
$items['XX/vocabulary/jenis_dokumen'] = array(
'title' => 'Add Term',
'page callback' => 'MYMODULENAME_taxonomy_add_term_page',
//'page arguments' => array(2),
'access arguments' => array('administer taxonomy'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
return $items;
}
function MYMODULENAME_taxonomy_add_term_page(){
$output = '';
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
$vocabulary = taxonomy_vocabulary_load(3, FALSE);
$output .= taxonomy_add_term_page($vocabulary);
return $output;
}
?>
Create your own custom module and copy & paste above code into that module.
NOTE : Above code is developed for Drupal 6
Hope it helps.
Abhishek Sawant
Drupal Developer
thanks for your quick
thanks for your quick reply.
i have tried a code. i get Fatal error: Call to undefined function taxonomy_add_term_page()
I think this cause a problem
$output .= taxonomy_add_term_page($vocabulary);In D6 taxonomy.admin.inc:
function taxonomy_add_term_page($vocabulary) {drupal_set_title(t('Add term to %vocabulary', array('%vocabulary' => $vocabulary->name)));
return drupal_get_form('taxonomy_form_term', $vocabulary);
}
and D7 does not have.
http://kamicetak.com
http://desain.kamicetak.com
after try to modify your
after try to modify your code, now i have success with this.
$vocabulary = taxonomy_vocabulary_load(2, FALSE);module_load_include('inc', 'taxonomy', 'taxonomy.admin');
return drupal_render(drupal_get_form('taxonomy_form_term', $vocabulary));
but, there is a default value in field name 'Jenis Dokumen'
how can i get blank (no value) in field?
http://kamicetak.com
http://desain.kamicetak.com
To get blank form
To get blank form you can use below code, but when you submit form which will throw an error.
return drupal_get_form('taxonomy_form_term', array(), $vocabulary);We have to find it another way to resolve this.
Please look at this :
http://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.admin.inc/function/taxonomy_form_term/7
We should do something like the following as per the above API or I hope we need to create a patch for it.
drupal_get_form('taxonomy_form_term', $form, &$form_state, $edit = array(), $vocabulary);Regards,
Veera Prasad Dagudu
www.drup-all.com
thanks. it's useful
thanks.
it's useful
http://kamicetak.com
http://desain.kamicetak.com