Skip to Content Skip to Menu

Article custom fields

18 hours 53 minutes ago #341853 by Proficookware
Article custom fields was created by Proficookware
Hello, 
I would like to use CB Auto Actions together with CB Activity to show not only the article title when a new Joomla article is created, but also the values of the article’s custom fields. 
For example, when a new article is published, the activity stream should display the article title plus selected Joomla custom field values. 
I already set up an Auto Action with trigger onContentAfterSave and context = com_content.article, so the activity entry is created.

However, I don’t know how to include Joomla article custom fields in the activity message.  Is it possible to access article custom fields directly in Auto Actions, or is there another recommended way to output these values in the Activity stream? 

Thank you for your guidance.
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 49501
  • Thanks: 8477
  • Karma: 1465
9 hours 39 minutes ago #341862 by krileon
Replied by krileon on topic Article custom fields

I would like to use CB Auto Actions together with CB Activity to show not only the article title when a new Joomla article is created, but also the values of the article’s custom fields.
For example, when a new article is published, the activity stream should display the article title plus selected Joomla custom field values.

Best way to do that is override the template file and add whatever details you want for articles. To do this within your hosting panel navigate to the below directory.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates

Now create a new folder. For the purpose of this example lets call that folder "custom". This should give you the below structure.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/custom

Now we need to create the directories for overriding that template file. Create the necessary directories until you've the following structure.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/custom/activity/core

Next navigate to that same directory structure in the default template. So this should bring you to the below.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/activity/core

Finally copy "article.php" to your custom template structure, which should give you the following.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/custom/activity/core/article.php

You've successfully created your own template that exclusively overrides article activity display. Now within CB Activity > Parameters > General set "Template" to "custom". Your template will now be applied to all of CB Activity.

You can then freely edit "article.php" and add whatever you like. You'll need to utilize Joomla APIs to pull in the custom fields and render them however you like.

I already set up an Auto Action with trigger onContentAfterSave and context = com_content.article, so the activity entry is created.

This isn't necessary. CB Activity has built in activity logging for this. You can enable it in CB Activity > Parameters > Activity.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum