PageTheme registerAssets determine if logged in
Permalink
I want to create an if/else statement that when user is not in edit mode, I will not provide the jquery asset, but when he/she is in edit mode, I will not show the provideAsset code below.
I can't seem to find any documentation regarding that for Concrete 5.7
Thank you so much.
I can't seem to find any documentation regarding that for Concrete 5.7
namespace Application\Theme\SampleTheme; use Concrete\Core\Page\Theme\Theme; class PageTheme extends Theme { public function registerAssets() { $this->providesAsset('javascript', 'jquery'); } protected $pThemeGridFrameworkHandle = 'foundation'; }
Thank you so much.
Hi :)
But if I don't do it, I will have to copies of jQuery for my site, the 1.11.3 that Concrete5 use, and the 2.1.4 jQuery version I use. I tried using 2.1.4 version but when I edit block, it became buggy.
So what I do when I edit block, is comment out that provideAsset line so I can use concrete5's jquery version instead.... which is kind of ugly. :) I was hoping there is a way to switch versions.
Client is very concerned about speed and having two versions of jQuery on site would have impact on performance.
But if I don't do it, I will have to copies of jQuery for my site, the 1.11.3 that Concrete5 use, and the 2.1.4 jQuery version I use. I tried using 2.1.4 version but when I edit block, it became buggy.
So what I do when I edit block, is comment out that provideAsset line so I can use concrete5's jquery version instead.... which is kind of ugly. :) I was hoping there is a way to switch versions.
Client is very concerned about speed and having two versions of jQuery on site would have impact on performance.
Okay, that is a different situation.
Outside of browser support, is there a reason why you are using jQuery 2.x?
I agree that loading jQuery 1.x and 2.x at the same time is not recommended.
Outside of browser support, is there a reason why you are using jQuery 2.x?
I agree that loading jQuery 1.x and 2.x at the same time is not recommended.
Hi again :)
I'm using jQuery 2.1.4 as it's the default of foundation framework. I'm using foundation as grid framework for my concrete5 theme.
I'm using jQuery 2.1.4 as it's the default of foundation framework. I'm using foundation as grid framework for my concrete5 theme.
I believe Foundation 5 should work just as well with jQuery 1.x.
The Fundamental theme found in the marketplace is an example of using jQuery 1.x with Foundation 5.
If you still have reservations, check the source of their demo site.
http://fundamental.c5hub.com/
More information on jQuery 1.x versus jQuery 2.x:
http://blog.jquery.com/2013/04/18/jquery-2-0-released...
The Fundamental theme found in the marketplace is an example of using jQuery 1.x with Foundation 5.
If you still have reservations, check the source of their demo site.
http://fundamental.c5hub.com/
More information on jQuery 1.x versus jQuery 2.x:
http://blog.jquery.com/2013/04/18/jquery-2-0-released...
Hi!
Thank you for the article link. According to that link, "With the release of jQuery 2.0, there are a few environments where the jQuery team will no longer support use of the 1.x line because 2.x is a far better choice. "
I'll be keeping both for now and just comment/uncomment.... uggh ugly, but i'd like jQuery 2.0 running when visitors visit the website.
Hopefully Concrete5 team will develop a feature where it will be easy to switch versions for assets if logged in or not.
Thank you for the article link. According to that link, "With the release of jQuery 2.0, there are a few environments where the jQuery team will no longer support use of the 1.x line because 2.x is a far better choice. "
I'll be keeping both for now and just comment/uncomment.... uggh ugly, but i'd like jQuery 2.0 running when visitors visit the website.
Hopefully Concrete5 team will develop a feature where it will be easy to switch versions for assets if logged in or not.
I don't believe you have to conditionally load jQuery this way.
While in Edit Mode, jQuery is a required asset that concrete5 needs to function, it will load its own copy if the theme does not require or provide it.
To double check this, I commented out the jQuery require in a theme page_theme.php. As expected, concrete5 loads its own.