Skip to Content Skip to Menu

OpenGraph tags in activity posts?

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 429
  • Thanks: 38
  • Karma: 3
  • Add-ons
7 months 3 weeks ago #339617 by liaskas
Replied by liaskas on topic OpenGraph tags in activity posts?
Thank you for your reply Krileon but not so helpful for me that i am not a programmer!

So let me put things in an order so that i can understand what to do...

Created type Code auto action. Triggers: activity_onDisplayActivity, User: Automatic, Access Everybody.
Conditions... Field: Value, Custom Value: [var3_isRow], Operator: Equal To, Value: 1.

Now regarding your blog post, you mention...

Simply add &format=jsonapi to the auto action URL

Where do i have to add it? Somewhere inside the above Code Auto Action? Where is the Auto Action URL?

Thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 49329
  • Thanks: 8437
  • Karma: 1465
7 months 3 weeks ago #339623 by krileon
Replied by krileon on topic OpenGraph tags in activity posts?
In that trigger var2 is the activity post as per the trigger helper. This means you can access all the posts data through var2.

So for example [var2_message] would be the message of the activity post. Problem is that's unprocessed. So to process it into something clean enough for opengraph you'll want to enable format functions under the parameters tab. Once done you can use the below.
Code:
[cb:parse function="getNotificationTitle" class="var2" /]

That will give you a clean meta description for a post.

Where do i have to add it? Somewhere inside the above Code Auto Action? Where is the Auto Action URL?

You don't add that anywhere. That's for accessing an auto action directly.

After CB 3.x we'll be converting all CB plugins into standard Joomla extensions (we won't have our own plugin management anymore). At that point we'll just integrate with Joomla more directly and automate schema and opengraph preparation. For now though you'll have to use this trigger approach, which I know can be a bit complicated at times so I do apologize.


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.

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 429
  • Thanks: 38
  • Karma: 3
  • Add-ons
7 months 3 weeks ago #339634 by liaskas
Replied by liaskas on topic OpenGraph tags in activity posts?
Thank you for your reply Krileon. We are getting closer!

Currently we have the following auto action:

Global
Triggers: activity_onDisplayActivity
Type: Code
User: Automatic
Access: Everybody

Conditions
Field: Value
Custom Value: [var3_isRow]
Operator: Equal To
Value: 1

Action
Method: Header
Code: <meta property="og:title" content="[cb:parse function="getNotificationTitle" class="var2" /]" />

AND HERE IS THE RESULT...

The post as it shows on activity...
 

The post info as the are shared on FB...
 

Please advise... thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 49329
  • Thanks: 8437
  • Karma: 1465
7 months 3 weeks ago #339636 by krileon
Replied by krileon on topic OpenGraph tags in activity posts?
You have to supply the entirety of the opengraph data. For sites like X (Twitter) you're also going to need to use twitter cards data. Below is an example that more closely matches CB SEO output.

Global
Triggers: activity_onDisplayActivity
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Value
Custom Value: [var3_isRow]
Operator: Equal To
Value: 1
Action
Method: Header
Code:
Code:
<meta property="og:type" content="website" /> <meta property="og:site_name" content="[cb:parse function="encode" method="html"][cb:config param="sitename" /][/cb:parse]" /> <meta property="og:title" content="[cb:parse function="encode" method="html"][username][/cb:parse]" /> <meta property="og:description" content="[cb:parse function="encode" method="html"][cb:parse function="getNotificationTitle" class="var2" /][/cb:parse]" /> <meta property="og:image" content="[cb:parse function="encode" method="html"][avatar][/cb:parse]" /> <meta property="twitter:card" content="summary" /> <meta property="twitter:title" content="[cb:parse function="encode" method="html"][username][/cb:parse]" /> <meta property="twitter:description" content="[cb:parse function="encode" method="html"][cb:parse function="getNotificationTitle" class="var2" /][/cb:parse]" /> <meta property="twitter:image" content="[cb:parse function="encode" method="html"][avatar][/cb:parse]" />
Parameters
Format Functions: Yes

Posts don't really have titles and getting the contents of the post is complicated. getNotificationTitle is an amalgamation of post title and message that's safe for sharing and has been processed. With the above example it sets the opengraph title to the username and the description to the getNotificationTitle result. It's important to use the html encoding format function to apply htmlspecialchars to the results of substitutions or you could insert broken html. Image is just set to avatar.

The above also sets this same information into twitter card metadata since CB SEO also does this automatically.

If you need this to be tailored to specific activity posts it will get complicated. You'll need to use IF substitutions and probably have to utilize PHP to get whatever information you're needing. However since the URL is to a post and not the article in the post the above metadata would be accurate for such a URL.

Note this doesn't guarantee a site will even parse this though. It will be inserted to the header as specified, but applications and other websites do not have to use this metadata.


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