Skip to Content Skip to Menu

Assign a CB Auto Action to one specific page?

55 minutes ago #343904 by BobBriscoe
How do I write inline javascript early in the head of one specific page.
I assume I should use a CB Auto Action of:
  • type: code
  • trigger: onBeforeCompileHead
  • Method: javascript(inline). 
But there's no way (that I can see) to assign such an action to one specific page? 

Hacked workround: I have used the above approach, but wrapped my code in an 'if' that matches the path of the specific page. But this surely can't be the proper approach, because it adds the code to every page, including backend pages.
 

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 50412
  • Thanks: 8624
  • Karma: 1472
28 minutes ago #343905 by krileon
Replied by krileon on topic Assign a CB Auto Action to one specific page?
I'd suggest just using CB Content Module instead. You can then assign it to your menu item. CB Content Module can output JavaScript, jQuery, and CSS in addition to regular content.

If there isn't a menu item to assign to or you still want to use onBeforeCompileHead then you'd need to add a condition to check for the URL. You can substitute in URL parameters using [get_PARAMETER] as well for easy access to parameter checks. PHP conditions can also be used to use Joomla API to retrieve the current URL and do checks against it however you need.


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