Skip to Content Skip to Menu

Plugin to override Metadata

  • Greystoke
  • Greystoke
  • OFFLINE
  • Posts: 8
  • Thanks: 0
  • Karma: 0
7 years 4 months ago #295413 by Greystoke
Plugin to override Metadata was created by Greystoke
Hi,

Can anyone tell me where I have gone wrong with this CB plugin.

It is not overriding the Meta description.
Am I using the wrong Trigger.

Some of the code has been removed for debugging.
Code:
<?php if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); } global $_PLUGINS; $_PLUGINS->registerFunction( 'onAfterUserProfileDisplay', 'metaOverride', 'getcbmetaTab' ); class getcbmetaTab extends cbTabHandler { function metaOverride( $user ) { global $_CB_framework; $cbUser = CBuser::getInstance( $user->id ); if ( ! $cbUser ) { $cbUser = CBuser::getInstance( null ); } $meta_tag = 'description'; $meta_data = 'test'; if ( $meta_tag && $meta_data ) { $_CB_framework->document->addHeadMetaData( $meta_tag, $meta_data ); } } } ?>

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
7 years 4 months ago #295421 by krileon
Replied by krileon on topic Plugin to override Metadata
A plugin to adjust metadata shouldn't be necessary. Edit your Joomla menu item to CBs profile page and adjust the metadata there. CB parses for it using our setMenuMeta function and will pass it through substitutions as well (to get the displayed users information be use to use user="#displayed" in your substitutions).


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.

  • Greystoke
  • Greystoke
  • OFFLINE
  • Posts: 8
  • Thanks: 0
  • Karma: 0
7 years 4 months ago #295426 by Greystoke
Replied by Greystoke on topic Plugin to override Metadata
Hi,

The plugin is needed as CB has been modified to allow a user to have multiple profile pages under the one username.

The plugin is getting the correct info from the users profile, but I need to pass that to the Metadata description.

Is it no longer possible to use a plugin to do this in CB 2

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
7 years 4 months ago #295459 by krileon
Replied by krileon on topic Plugin to override Metadata
That is the appropriate trigger to be acting on, but beyond that I'm not here to debug your code for you; review existing plugins for examples. The easiest approach would be to use CB Auto Actions as it has a Code action with a Method option specifically for adjusting headers easily. Our setMenuMeta function however is executed after that trigger so if you're setting metadata in the menu item it'll override whatever you're doing in that trigger.


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.

  • Greystoke
  • Greystoke
  • OFFLINE
  • Posts: 8
  • Thanks: 0
  • Karma: 0
7 years 4 months ago #295476 by Greystoke
Replied by Greystoke on topic Plugin to override Metadata
Hi,

Not expecting you to debug the code.
The code is fine, the trigger is no good as you said yourself the setMenuMeta function is executed after that trigger.

Is there a trigger that will override the setMenuMeta function.

I didn't want to have to use CB Auto Actions.

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
7 years 4 months ago #295503 by krileon
Replied by krileon on topic Plugin to override Metadata
The trigger works perfectly fine. Your plugin either isn't loaded or your metadata is being overridden. setMenuMeta will not override your metadata if nothing is specified in your Joomla menu item to CBs profile page.

Is there a trigger that will override the setMenuMeta function.

No, just don't specify any metadata in your Joomla menu item to CBs profile page.


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