Drupal api

지각생 연습장
(forum)
 
3번째 줄: 3번째 줄:
 
= node =
 
= node =
 
node 추가, 관리 관련
 
node 추가, 관리 관련
 +
* node_save(&$node) : $node->title 등을 설정해 준 후, 이 함수를 실행. $node->nid 가 empty면, 새 node라 보고, 추가하게 된다.
 +
 
= forum =
 
= forum =
 
* forum_insert($node) : 포럼에 추가할 때는 이것만 해주면 되겠다. $node에 대해서도 딱히 해주는게 전혀 없다.
 
* forum_insert($node) : 포럼에 추가할 때는 이것만 해주면 되겠다. $node에 대해서도 딱히 해주는게 전혀 없다.
 
* 기타 유용할 것 같은 : forum_get_forums, forum_get_topics, forum_taxonomy ..
 
* 기타 유용할 것 같은 : forum_get_forums, forum_get_topics, forum_taxonomy ..
 +
* forum을 만드는 것은, 그냥 term_data 를 하나 추가해 주는 것이다. (taxonomy_save_term) forum 테이블에는 각 노드와 term 의 아이디가 연결된다.
 +
* term_hierarchy 테이블에 tid, parent 쌍에 forum, forum_container 의 tid 를 넣어준다.
 +
* term_node 테이블에는 nid, tid 쌍에 node id, forum 의 tid 를 넣어준다. 이건, forum topic 으로 넣을때와, 그 토픽에 카테고리 지정할때 하면 되겠다.
 +
* forum container 도 하나의 포럼이다. 포럼으로 생성한다음 variable_get, _set 함수를 이용해 forum_containers 의 value에 그 아이디를 추가해주면 된다.
 +
 
= files =
 
= files =
첨부파일 처리
+
첨부파일 처리. 얼핏 못 찾겠다.
 +
* 그냥 files, file_revisions 테이블에 바로 써도 될 듯. files는 nid, file_revisions는 vid 로 접근하면 된다
 +
 
 
= category =
 
= category =
 
카테고리/taxonomy(hierarchy)/tag 등
 
카테고리/taxonomy(hierarchy)/tag 등
 +
== taxonomy_save_vocabulary ==
 +
아래 부분만 활용하면 될듯
 +
<pre>
 +
  $edit['vid'] = db_next_id('{vocabulary}_vid');
 +
    db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
 +
    foreach ($edit['nodes'] as $type => $selected) {
 +
      db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
 +
    }
 +
    module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit);
 +
    $status = SAVED_NEW;  //이 줄은 불필요할지도.
 +
 +
  cache_clear_all();
 +
</pre>
  
 
= comment =
 
= comment =

2007년 3월 26일 (월) 23:57 기준 최신판

개인 도구