php - Drupal build custom query between taxonomy and content -
i received project coded else on drupal 7 apparently not follow of drupal's standards , coded website overwriting template system (and late modify or edit of current structure).
i have following issue need build custom query:
the data in cms created such:
category (created in taxonomy) -> subcategory (created content type) -> item (created content type)
when adding entries in cms, workflow such:
- first create main category taxonomy (named category)
- the create subcategory contents
- when adding/editing subcategory, select parent category radio list
- and items selected checkbox list
i have taken screenshots cms make things clearer regarding structure, can found here:
the problem not being able build view @ all, need create custom query can following:
- read categories
- read subcategories belonging each category
- read items under each category
- with php, generate custom html using loops on above data
the purpose of on website, user able click category, , list of subcategories. when subcategory clicked, items in can seen.
in typical php/mysql, query process (assuming no joins):
<?php $categories = query('select * categories'); while ($category = fetcharray($catetgories)) { $subcategories = query('select * subcategories category = $category['id']); while ($subcategory = fetcharray($subcategories)) { $items = query('select * items subcategory = $subcategory['id']); } } ?>
i need able replicate above doing query items of taxonomy "category", find subcategories (content type) belong it, , find items belong subcategory
you can use drupal api function taxonomy_get_tree taxonomy tree , under each subcategory iteration use entityfieldquery load item (node) list.
but recommend create custom ajax field 3 select form elements , load values dependently.
Comments
Post a Comment