uzielweb

Fetch custom fields in a module

Jan 21st, 2021 (edited)
809
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $baseurl = JUri::base();
  3. $article = JTable::getInstance("content");
  4. $article_id = JRequest::getVar('id');
  5. $article->load($articleid);
  6. $cactid = $article->get('catid');
  7.  
  8. JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); //load fields helper
  9. // incorrect is bellow
  10. // $fields  = FieldsHelper::getFields('com_content.article', $article, true);
  11. // correct is bellow
  12. $fields  = FieldsHelper::getFields('com_content.article', ['id'=> $article_id]);
  13. ?>
  14. <?php foreach ($fields as $field) : ?>
  15. <?php $value = $field->value;
  16. echo $value;?>
  17. <?php endforeach;?>            
  18.  
  19.  
RAW Paste Data