Advertisement
uzielweb

k2 items list based on categories and parent categories

Feb 8th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. defined('_JEXEC') or die;
  3. $module_categories = $params->get('categories');
  4. foreach ($module_categories as $category){
  5. $ids[]=$category
  6. }
  7. $db = JFactory::getDBO();
  8. $db->setQuery("
  9. select * from #__k2_items as i
  10. inner join
  11. #__k2_categories as c
  12. where (i.catid = c.id and c.id in (".implode(','$ids).")
  13. or (i.catid = c.parent and c.parent in (".implode(','$ids).")
  14. order by extra_fields asc");
  15. $items = $db->loadObjectList();
  16.  
  17. ?>
  18.  
  19.  
  20. <?php foreach ($items as $count => $item) : ?>
  21. <?php $extra_field = json_decode($item->extra_fields);?>
  22. <?php if ((in_array($item->parent,$module_categories)) or (in_array($item->catid,$module_categories))) :?>
  23. <?php if (($extra_field['0']->value >= date('Y-m-d')) and ($item->published == '1')) :   ?>
  24. <div class="kevent-category">
  25.     <b>CATID: <?php echo $item->catid; ?></b>  <b>PARENT: <?php echo $item->parent; ?></b>
  26. </div>
  27.  
  28. <div class="kevent-title">
  29.     <?php echo $item->title; ?>
  30.     </div>
  31.        <div class="kevent-category">
  32.     <i><?php echo $item->name; ?></i>
  33. </div>
  34.     <div class="kevent-date">
  35.     <i><?php echo $extra_field['0']->value; ?></i>
  36. </div>
  37. <div class="kevent-date">
  38.     <i><?php echo JHTML::_('date', $extra_field['0']->value,JText::_('DATE_FORMAT_LC1'), 'UTC'); ?></i>
  39. </div>
  40.      <?php endif; ?>
  41.     <?php endif; ?>
  42. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement