Assets question: Jquery UI

Permalink
Hi,

I'm building a site in 5.7. The site needs JQuery UI so I want to load the asset, so in my page_theme.php file I've added it to the registerAssets function:

public function registerAssets() {
...
$this->requireAsset('javascript', 'jquery/ui');
...
}

However, when logged out it isn't loading Jquery UI. Any ideas please? :)

Dave

madesimplemedia
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi madesimplemedia,

I believe you need to refresh the theme by uninstalling and reinstalling it.
madesimplemedia replied on at Permalink Reply
madesimplemedia
Hi Karl

Thanks for the reply. I did try that and it didn't seem to help, but I think I'll try it again...

Cheers
Dave
madesimplemedia replied on at Permalink Reply
madesimplemedia
OK so I just activated Elemental, Removed my theme then cleared the cache.
Then I re-installed my theme and it's still not loading jqueryUI - it is loading jQuery though.
ramonleenders replied on at Permalink Reply
ramonleenders
As a work-around, you could try to provide this asset and paste the code into your head. It shouldn't double load in any case, as you are stating you provide it yourself.

$this->providesAsset('javascript', 'jquery/ui');
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks but now I just get
Call to undefined method Concrete\Core\Page\View\PageView::providesAsset()
ramonleenders replied on at Permalink Reply
ramonleenders
It shouldn't call "Concrete\Core\Page\View\PageView", but "Concrete\Core\Page\Theme\Theme" instead...

Does your class PageTheme extend "\Concrete\Core\Page\Theme\Theme"?

class PageTheme extends \Concrete\Core\Page\Theme\Theme {
// your registerAssets function and all that
}
madesimplemedia replied on at Permalink Reply
madesimplemedia
Yes that's exactly what it's set to do
ramonleenders replied on at Permalink Reply
ramonleenders
Can you copy/paste the whole page_theme.php file? And what version number are you using, perhaps this is a Concrete5 bug... but as it tries to call the wrong class, it seems it's not extending the correct class... Can anyone else take a look at this too (are the tech-y people around)?
madesimplemedia replied on at Permalink Reply
madesimplemedia
Here you go:

<?php
namespace Application\Theme\Gbliners;
class PageTheme extends \Concrete\Core\Page\Theme\Theme {
   public function registerAssets() {
        //$this->providesAsset('javascript', 'bootstrap/*');
        $this->providesAsset('css', 'bootstrap/*');
        $this->providesAsset('css', 'blocks/form');
        $this->providesAsset('css', 'blocks/social_links');
        $this->providesAsset('css', 'blocks/share_this_page');
        $this->providesAsset('css', 'blocks/feature');
        $this->providesAsset('css', 'blocks/testimonial');
        $this->providesAsset('css', 'blocks/date_navigation');
        $this->providesAsset('css', 'blocks/topic_list');
        $this->providesAsset('css', 'blocks/faq');
        $this->providesAsset('css', 'blocks/tags');


It Concrete5 v 5.7.5.2
madesimplemedia replied on at Permalink Reply
madesimplemedia
I've hacked it for now:

<?php 
   global $u;
   $u = new User(); 
   if ($u->isLoggedIn()) { 
   } else {
      print "<link rel=\"stylesheet\" href=\"/concrete/css/jquery-ui.css\" type=\"text/css\" />";
      print "<script src=\"/concrete/js/jquery-ui.js\"></script>";
   }
?>
mnakalay replied on at Permalink Reply
mnakalay
To start with it seems all your providesAsset should really be requireAsset unless you are actually providing all those files
mnakalay replied on at Permalink Reply
mnakalay
Otherwise I tried the code with requireasset and jquery ui loads normally
mnakalay replied on at Permalink Reply
mnakalay
oh and the way you did it is not recommended. If somebody installs a block on that site that provides its own version of jquery ui or requires core jquery ui, there will be no awareness between the theme and the block and jquery ui will be loaded twice