Keyword

How to unset "k2.js"

More
10 years 9 months ago - 10 years 9 months ago #116713 by irmax
How to unset "k2.js" was created by irmax
Previously, I could remove (unset) "k2.js" from the header as below:
unset($this->_scripts[$this->baseurl .'/components/com_k2/js/k2.js']);

But now, after upgrading to version 2.6.7, that doesn't work anymore. That's certainly because the js file is called with a new path:
/components/com_k2/js/k2.js?v2.6.7&sitepath=/

So I have two different question:

1. How should I unset the k2.js file? (Probably with preg_match_all)

2. From where the k2.js is declared? I mean, where is the code that add k2.js to the header?

Thanks in advance

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #116714 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to unset "k2.js"
Hello irmax,

The script is loaded like this:
$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.7&sitepath='.JURI::root(true).'/');

You can modify the unset rule to match the loading

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
10 years 9 months ago #116715 by irmax
Replied by irmax on topic Re: How to unset "k2.js"
Thanks, Krikor. Now it works. But, what if I upgrade k2? In that case, the version will change and the unset rule will no longer work, because the version is present within the path:
unset($this->_scripts[JURI::root(true).'/components/com_k2/js/k2.js?v2.6.7&sitepath='.JURI::root(true).'/']);
I think a regex should be used. Would you please help me with that?

And also, would you please answer my second quesion, repeated below:

From where the k2.js is declared? I mean, where is the code that add k2.js to the header?

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

  • thongtran
  • thongtran's Avatar
  • Offline
  • New Member
  • CEO at foobla.com
More
10 years 8 months ago #116716 by thongtran
Replied by thongtran on topic Re: How to unset "k2.js"
That file is located in JOOMLA/plugins/system/k2/k2.php

Hope that helps.

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

More
10 years 3 months ago #116717 by Robert J. Hantson
Replied by Robert J. Hantson on topic Re: How to unset "k2.js"
I've been dealing with this problem for quite a while now, and there really doesn't seem to be an explination of why this is occurring. Just a few lines of code to "unset" with no explanation of where to put this code --- do I have to put this code in every componant that has this problem? Because its happenign on just about every page that isn't a content page on my sites and I can't use this if this is going to be the case.

I'm about to trash this componant on all our sites and find a different solution - this is a problem that has been in place with this version since last year, and noone seems to have a real answer on how to actually stop it from occurring?

RH

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

More
10 years 3 months ago #116718 by Kelsey Brookes
Replied by Kelsey Brookes on topic Re: How to unset "k2.js"
Robert, you add the unset code to the top of your template index.php, right before the closing ?> and before the start of any doctype declarations or the opening HTML tag.

It's not necessary to do this to run k2 - it's only necessary if you don't want to use k2's javascript file.

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

More
7 years 6 months ago #158911 by eaweb
Replied by eaweb on topic How to unset "k2.js"
Hello, delete this:
$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.frontend.js?v2.7.1&sitepath='.JURI::root(true).'/');
in /plugins/system/k2/k2.php

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

More
7 years 6 months ago #158915 by Kelsey Brookes
Replied by Kelsey Brookes on topic How to unset "k2.js"
I was initially going to say that eaweb's method is a bad idea because every update to K2 has the potential to break the fix.

But then I realised the current method of overriding in the template index file also breaks with every single update.

This is because the unset command needs to include the version number, which make this whole exercise a bit painful.

So I'm wondering if there's a way of getting the current version number so we can dynamically include it:
unset($this->_scripts[JURI::root(true).'/media/k2/assets/js/k2.frontend.js?'.echo $k2version.'&sitepath='.JURI::root(true).'/']);

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 6 months ago #158918 by Krikor Boghossian
Replied by Krikor Boghossian on topic How to unset "k2.js"
You can set K2 Version as a constant in order to easily change the version number.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 6 months ago #158936 by Kelsey Brookes
Replied by Kelsey Brookes on topic How to unset "k2.js"
I'd be very interested to know how to do that.

I've had a look in the language overrides and can't find 2.7.2 (which is the version number that appears in my K2 install) there.

Any clues on how I'd get started here?

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


Powered by Kunena Forum