Site login breaks bootstarp dropdown menus
Permalink
Environment: C5 5.7.5.9. Unix/Apaches/PHP => Chrome or FF.
After literally hours of diagnostics trying to determine why NO bootstrap dropdown menus work on my page, I gave up and asked for help. Of course the coworker I asked to look at the page said "The drop down menus work perfectly!" The difference we discovered is they stop working when you login, even if you are just viewing the page. I might understand them breaking in Edit mode, but not just viewing them.
Is this a bug or is there a C5 secret handshake (of course undocumented) to make bootstrap drop down menus still work when you are logged in?
I am to the point that I wish C5 had as much documentation as it has bugs. Can't someone do a "Fund Me" project and put some docs together?
Thanks,
Sean
After literally hours of diagnostics trying to determine why NO bootstrap dropdown menus work on my page, I gave up and asked for help. Of course the coworker I asked to look at the page said "The drop down menus work perfectly!" The difference we discovered is they stop working when you login, even if you are just viewing the page. I might understand them breaking in Edit mode, but not just viewing them.
Is this a bug or is there a C5 secret handshake (of course undocumented) to make bootstrap drop down menus still work when you are logged in?
I am to the point that I wish C5 had as much documentation as it has bugs. Can't someone do a "Fund Me" project and put some docs together?
Thanks,
Sean
I would be willing to bet that you are including a copy of jquery or bootstrap in your theme without having the proper "providesAsset" in your page_theme.php, so when you're logged in C5 includes it's copy of jquery and bootstrap and then it's loaded twice.
EXACTLY!
Thanks very much for your answer.
I did not see the difference in including the CSS and JS vs "provideAsset". Man what I would give for even a half ass "Users Guide" or "Programmers Ref."
Any hints where one might find:
A list of "provideAsset()" options like bootstrap css and js?
What others are there?
or just the syntax for including bootstrap and jquery?
Hints like: If you include bootstrap, does it include jquery or do I have to list both?
Again thanks for your answer.
Thanks very much for your answer.
I did not see the difference in including the CSS and JS vs "provideAsset". Man what I would give for even a half ass "Users Guide" or "Programmers Ref."
Any hints where one might find:
A list of "provideAsset()" options like bootstrap css and js?
What others are there?
or just the syntax for including bootstrap and jquery?
Hints like: If you include bootstrap, does it include jquery or do I have to list both?
Again thanks for your answer.
Take a look at the documentation and many of these questions are answered -http://documentation.concrete5.org/developers/designing-for-concret...
To answer a couple, here is the Asset List -http://documentation.concrete5.org/developers/appendix/asset-list,... jquery and bootstrap have to be listed separately as they can be required/provided separately, and if you are willing to search a little there is quite a bit of documentation but I do agree it's not structured in a very user friendly way.
To answer a couple, here is the Asset List -http://documentation.concrete5.org/developers/appendix/asset-list,... jquery and bootstrap have to be listed separately as they can be required/provided separately, and if you are willing to search a little there is quite a bit of documentation but I do agree it's not structured in a very user friendly way.
Thanks again. It is just so frustrating to waste 6 to 7 hours of a work day because you cant find the simplest things.
People send me these links to things that I just cannot find. Google searches come up with nothing or items from 5.6 and before that no longer apply. I am pretty sure it is just me, but 90% of my searches that are for 5.7 take me to the source code. That is less than optimal.
I really appreciate you answers though. Thanks again.
People send me these links to things that I just cannot find. Google searches come up with nothing or items from 5.6 and before that no longer apply. I am pretty sure it is just me, but 90% of my searches that are for 5.7 take me to the source code. That is less than optimal.
I really appreciate you answers though. Thanks again.
HI again.
UPDATE: For what it is worth I have tracked down that when logged in C5 includes script tag for "/concrete/js/bootstrap/dropdown.js" which breaks my dropdowns! How can I prevent that file from loading when logged in? I have tried both:
$this->providesAsset('javascript', 'bootstrap/*');
$this->providesAsset('javascript', 'bootstrap/dropdown');
in page_theme.php registerAssests() {}.
I am also confused why bootstrap dropdowns work fine with bootstrap.min.js, but adding theat file kills them. No errors, just no drop downs.
I thought I was getting this, but I can't find any combination that makes this work. In my template I need bootstrap 3 (CSS and JS) as well as jQuery (1.n). I am thinking that's got to true for a high percentage of templates.
I can ONLY find one way to get my bootstrap drop menus to work in user mode. And then they fail when I login. In my <template_name>.php I have this code snippet:
(multi.css just loads fonts, etc).
I have tried every combination of requireAsset() and providesAsset() I can think of. Can you lay it out for me? I must be missing something. Perhaps related to the problem, I am VERY thin on what goes in page_theme.php and can't find any docs about it at all! Perhaps that is the underlying problem.
Sorry to be such a newbie, and again thanks for your help.
Sean
UPDATE: For what it is worth I have tracked down that when logged in C5 includes script tag for "/concrete/js/bootstrap/dropdown.js" which breaks my dropdowns! How can I prevent that file from loading when logged in? I have tried both:
$this->providesAsset('javascript', 'bootstrap/*');
$this->providesAsset('javascript', 'bootstrap/dropdown');
in page_theme.php registerAssests() {}.
I am also confused why bootstrap dropdowns work fine with bootstrap.min.js, but adding theat file kills them. No errors, just no drop downs.
I thought I was getting this, but I can't find any combination that makes this work. In my template I need bootstrap 3 (CSS and JS) as well as jQuery (1.n). I am thinking that's got to true for a high percentage of templates.
I can ONLY find one way to get my bootstrap drop menus to work in user mode. And then they fail when I login. In my <template_name>.php I have this code snippet:
<?=Loader::element('header_required'); ?> <?php $this->requireAsset('javascript', 'jquery'); ?> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="<?=$view->getThemePath()?>/css/bootstrap/bootstrap.css" rel="stylesheet" /> <script src="<?=$view->getThemePath()?>/js/bootstrap.min.js"></script> <link href="<?=$view->getThemePath()?>/css/multi.css" rel='stylesheet' type='text/css'>
(multi.css just loads fonts, etc).
I have tried every combination of requireAsset() and providesAsset() I can think of. Can you lay it out for me? I must be missing something. Perhaps related to the problem, I am VERY thin on what goes in page_theme.php and can't find any docs about it at all! Perhaps that is the underlying problem.
Sorry to be such a newbie, and again thanks for your help.
Sean
The requireAsset doesn't go in the page templates, it goes in the page_theme.php in your theme folder, take a look at this documentation, I think it will help:http://documentation.concrete5.org/tutorials/requireasset-and-provi...
Also, you need to make sure your cache is turned off for development or you will run into all kinds of weird things going on.
Also, you need to make sure your cache is turned off for development or you will run into all kinds of weird things going on.
In hopes that this will help future explorers .. I watched Andrews video on designing your first theme. Of course nothing is mentioned about the PageTheme class in that intro video. However, what is missing is that your ..\Themes\"Theme Name" folder MUST match your namespace's CamelCase name with _ lowercase letter for all CAPITALs, again ONLY for your page_theme.php to be included. Controller.php and <template_name>.php files were just fine in the "DeltaSpas" folder. So my:
namespace Application\Theme\DeltaSpas;
REQUIRED a folder named delta_spas. Everything else about my custom theme was fine with a folder named DeltaSpas. The important thing here is that your page theme is just ignored in the wrong folder name (of course). That explains why regardless of the contents of my page_theme.php I could not get any of this to work.
I discovered this by adding a line to page_theme.php's registerAssests() function like "GIVE ME AN ERROR" and got no error!
Thanks again hutman for your help as it did point to the underlying problem of C5 including assets twice in admin mode.
namespace Application\Theme\DeltaSpas;
REQUIRED a folder named delta_spas. Everything else about my custom theme was fine with a folder named DeltaSpas. The important thing here is that your page theme is just ignored in the wrong folder name (of course). That explains why regardless of the contents of my page_theme.php I could not get any of this to work.
I discovered this by adding a line to page_theme.php's registerAssests() function like "GIVE ME AN ERROR" and got no error!
Thanks again hutman for your help as it did point to the underlying problem of C5 including assets twice in admin mode.