Skip to Content Skip to Menu

CB Style Sheet and JavaScript links

  • MAYASIMA
  • MAYASIMA
  • OFFLINE
  • Posts: 183
  • Thanks: 22
  • Karma: 5
9 years 5 months ago - 9 years 5 months ago #264584 by MAYASIMA
CB Style Sheet and JavaScript links was created by MAYASIMA
I am adding CB Style Sheet and JavaScript links dynamically to the header of webpages. I do this based on various rules. However CB ads version numbers to it's Style Sheet and JavaScript files.
(I very much like this approach and which more extension builders would do the same.)

My question is if there is a way for me to dynamically update my links with the version number as well. Right now I just hard code the links. Because of this, every time I do a CB upgrade I need to change my code with the correct links/versions. Is there a way for me to add the correct version number dynamically. Does CB add the version numbers based on the CB version? If yes, were can I look for the value and/or in which file can I take a look to see how it is done right now.

Thanks,

Sima
Last edit: 9 years 5 months ago by MAYASIMA.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 5 months ago #264585 by krileon
Replied by krileon on topic CB Style Sheet and JavaScript links
The version is an MD5 based off the CB version, the file timestamp, and the domain. This prevents browser cache from causing wonky issues when we make a new release and the browser cached the CSS or JS file, which then causes style bugs or JS bugs temporarily.

If CB API is loaded you can use it to add to the header as follows.

CSS File:
Code:
$_CB_framework->document->addHeadStyleSheet( PATH_HERE );

JS File:
Code:
$_CB_framework->document->addHeadScriptUrl( PATH_HERE );

Our document API has quite a bit other usages in addition to those functions having additional usages. You can find the API at the below location for more detailed usage.

libraries/CBLib/CB/Legacy/CBdocumentHtml.php

If you just want to see how we do the version you can find that in the addVersionFileUrl function of the above file.


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