Bladeren bron

Fix wrong # of nodes exported in ODT

Yves Chedemois 15 jaren geleden
bovenliggende
commit
ee7d8e15cf
3 gewijzigde bestanden met toevoegingen van 9 en 1 verwijderingen
  1. BIN
      catalogue_template.odt
  2. 2 0
      fgcf.module
  3. 7 1
      fgcf.odt.inc

BIN
catalogue_template.odt


+ 2 - 0
fgcf.module

@@ -6,6 +6,8 @@
  * Non-features part of FGCF
  */
 include_once('fgcf.features.inc');
+// @todo remove
+//include_once('fgcf.import.inc');
 
 
 /**

+ 7 - 1
fgcf.odt.inc

@@ -45,6 +45,8 @@ function fgcf_odt_export_formations($filename) {
   // Create new odf object from the template.
   $odf = fgcf_new_odf($filename);
 
+  $count = 0;
+  $count_cat = array();
   // Identify replacement segment in the template.
   $thematique_1_boucle = $odf->setSegment('thematique_1_boucle');
 
@@ -59,8 +61,10 @@ function fgcf_odt_export_formations($filename) {
       // Iterate over secondary terms.
       $sub_tree = taxonomy_get_tree($vid, $term->tid);
       foreach ($sub_tree as $term_2) {
+        $count_cat[$term_2->tid] = 0;
         // Select nodes for that term.
-        $result = taxonomy_select_nodes(array($term_2->tid), 'or', 0, FALSE, 'n.nid ASC');
+        $sql = 'SELECT n.nid FROM {node} n LEFT JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d AND n.status = 1';
+        $result = db_query(db_rewrite_sql($sql), $term_2->tid);
         while ($row = db_fetch_array($result)) {
           // Insert replacements for the node in the nested 'formations_boucle'
           // loop.
@@ -68,6 +72,8 @@ function fgcf_odt_export_formations($filename) {
           $node = node_load($row['nid']);
           fgcf_odt_replace_node_formation($formation_boucle, $node);
           $formation_boucle->merge();
+          $count++;
+          $count_cat[$term_2->tid]++;
         }
       }