Skip to Content Skip to Menu

[#6778] Using JFactory in CB Auto Actions Code

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
7 years 1 month ago - 7 years 1 month ago #297210 by sysopcrew
I had just gotten an Auto Actions Code put together to put FB Open Graph in place using $doc = JFactory::getDocument() and a series of $doc->setMetaData('og:type', 'website', 'property'); lines to get everything in place. (I use the Phoca plugin for articles, but that doesn't load on GroupJive pages).

Then I upgraded to CB Auto Actions 7.0.0, and it seems JFactory doesn't load. Or it does in a different way, and I can't find how in the change log.

The previous CB Auto Actions.seemed like this would have worked. What changed in 7.0.0 that I need to know of to add <meta> tags to the <html><head></head> for proper Open Graph use on Group Jive pages?

--
David Riviera
Last edit: 7 years 1 month ago by krileon. Reason: Added [#6778] tag to subject

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

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
7 years 1 month ago - 7 years 1 month ago #297212 by sysopcrew
Replied by sysopcrew on topic Using JFactory in CB Auto Actions Code
PS—I am using JFactory and PHP so Open Graph is dynamic, such as:
Code:
$doc = JFactory::getDocument(); $title = $doc->getTitle(); $doc->setMetaData('og:title', $title , 'property'); $doc->setMetaData('og:url', 'https://example.com' . $_SERVER['REQUEST_URI'], 'property');

Rather than static OG <meta> in a Header code action object. It was working just before the CB Auto Action 7.0.0 upgrade, and nothing in the change log stands out. The Joomla System CB Auto Auction plugin is installed and published, just in case. No difference.

--
David Riviera
Last edit: 7 years 1 month ago by sysopcrew.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 1 month ago - 7 years 1 month ago #297215 by krileon
Replied by krileon on topic Using JFactory in CB Auto Actions Code
Appears to be an issue with the code action it self. Am fixing for a new build today.

forge.joomlapolis.com/issues/6778

Quickfix as follows if unable to wait for new build.

IN: components/com_comprofiler/plugin/libraries/CB/Plugin/AutoActions/Action/CodeAction.php
ON: Line
FROM:
Code:
$content = CBAutoActions::outputCode( $return, $this->autoaction(), $user, $this->variables() );
TO:
Code:
$autoaction = $this->autoaction(); $variables = $this->variables(); $content = CBAutoActions::outputCode( $code, $autoaction, $user, $variables );


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.
Last edit: 7 years 1 month ago by krileon.
The following user(s) said Thank You: sysopcrew

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

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
7 years 1 month ago #297252 by sysopcrew
Replied by sysopcrew on topic Using JFactory in CB Auto Actions Code
The new build is installed and the fix worked! Code: PHP. Output: None. Method:
Code:
$doc = JFactory::getDocument(); $title = $doc->getTitle(); $doc->setMetaData('og:image', 'https://example.org/image.jpg', 'property'); $doc->setMetaData('og:image:width', '1200', 'property'); $doc->setMetaData('og:image:height', '630', 'property'); $doc->setMetaData('og:title', $title , 'property'); $doc->setMetaData('og:description', 'My Slogan', 'property'); $doc->setMetaData('fb:app_id', '0123456789', 'property'); $doc->setMetaData('og:type', 'website', 'property'); $doc->setMetaData('og:url', 'https://example.org' . $_SERVER['REQUEST_URI'], 'property'); $doc->setMetaData('og:site_name', 'My Website', 'property');

I just gave the action all gj_onBefore*Display triggers. This adds the necessary dynamic Open Graph to all Group Jive pages. I use Phoca for OpenGraph on articles, but found that doesn't load on GJ.

CB OpenGraph could be a fun new Professional add-on… or CB Social Info, to do Twitter Cards, too; something that gives more global control across all CB plugins.

THANK YOU for the quick fix.

--
David Riviera

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 1 month ago #297262 by krileon
Replied by krileon on topic Using JFactory in CB Auto Actions Code

CB OpenGraph could be a fun new Professional add-on… or CB Social Info, to do Twitter Cards, too; something that gives more global control across all CB plugins.

A plugin specifically to do that would just be a mini CB Auto Actions so there's not much point. You can simply use a CB Auto Action for that. In most cases you don't even need to use PHP to output custom headers as CB Auto Actions has a usage built in just for that using Code action with Method set to Header to add custom substitution supported HTML to the page header.


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