coriolan
(Coriolan)
October 1, 2015, 7:33pm
1
Hi All,
I have a working webapp. In my config/main.php I have:
'preload'=>array(
'bootstrap',
),
'components'=>array(
'bootstrap' => array(
'class' => 'ext.yiibooster.components.Bootstrap',
'fontAwesomeCss' => TRUE,
),
Now, I need to generate XML content, and when I do, I get this:
<OpeningTag>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/css/bootstrap-yii.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/css/jquery-ui-bootstrap.css" />
<script type="text/javascript" src="/assets/732c015f/jquery.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/js/bootstrap-noconflict.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/bootbox/bootbox.min.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/notify/notify.min.js"></script>
<rest of XML />
</ClosingTag>
<script type="text/javascript">
/*<![CDATA[*/
jQuery('[data-toggle=popover]').popover();
jQuery('body').tooltip({"selector":"[data-toggle=tooltip]"});
/*]]>*/
</script>
This is the layout I’m using:
<?php
header("Content-type: text/xml");
header("Connection: close");
header("Expires -1");
?>
<?php echo $content; ?>
In the layout I’m not adding CSS/Javascript, but it gets added anyway ; When I remove ‘bootstrap’ from ‘preload’ in my config, the XML appears without all the extra CSS/Javascript data
Is there a simple way to disable the loading of bootstrap for specific layouts ? Or can I unload it for these ?
I found ways to enable it for specific layouts, but as that would have to be done for the entire webapp, that’s a lot of work !
Thanks for your inputs
oligalma
(Marc Oliveras)
October 2, 2015, 1:10am
2
You can just use registerScript and registerCss to load the files you want in the layouts you want.
http://www.yiiframework.com/wiki/800/how-to-register-scripts-and-css/
coriolan:
Hi All,
I have a working webapp. In my config/main.php I have:
'preload'=>array(
'bootstrap',
),
'components'=>array(
'bootstrap' => array(
'class' => 'ext.yiibooster.components.Bootstrap',
'fontAwesomeCss' => TRUE,
),
Now, I need to generate XML content, and when I do, I get this:
<OpeningTag>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/css/bootstrap-yii.css" />
<link rel="stylesheet" type="text/css" href="/assets/f2eefa0e/css/jquery-ui-bootstrap.css" />
<script type="text/javascript" src="/assets/732c015f/jquery.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/js/bootstrap-noconflict.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/bootbox/bootbox.min.js"></script>
<script type="text/javascript" src="/assets/f2eefa0e/notify/notify.min.js"></script>
<rest of XML />
</ClosingTag>
<script type="text/javascript">
/*<![CDATA[*/
jQuery('[data-toggle=popover]').popover();
jQuery('body').tooltip({"selector":"[data-toggle=tooltip]"});
/*]]>*/
</script>
This is the layout I’m using:
<?php
header("Content-type: text/xml");
header("Connection: close");
header("Expires -1");
?>
<?php echo $content; ?>
In the layout I’m not adding CSS/Javascript, but it gets added anyway ; When I remove ‘bootstrap’ from ‘preload’ in my config, the XML appears without all the extra CSS/Javascript data
Is there a simple way to disable the loading of bootstrap for specific layouts ? Or can I unload it for these ?
I found ways to enable it for specific layouts, but as that would have to be done for the entire webapp, that’s a lot of work !
Thanks for your inputs
Obviously Yii is automatically adding JS and CSS files. Remove this bootstrap component and see what will hapen.
coriolan
(Coriolan)
October 3, 2015, 4:21am
4
Hi Both,
Thanks for your replies.
I have tested to remove bootstrap - and that works - but it’s not a workable solution as I can’t add it to all my layouts.
Any suggestion selectively disable a component ?
You could use clientScript in your layout:
<?php Yii::app()->clientScript->reset(); ?>
reykel
(Rhpalacios66)
October 30, 2015, 10:05am
6
hey man you’re making a fatal use of assets, and worst I’ve seen this concept in some other coders. That’s wrong people. Good luck everyone…
coriolan
(Coriolan)
November 25, 2015, 11:24am
7
That did the trick - thank you
ngxtri
(Ngxtri)
December 24, 2015, 7:26pm
8
This did the trick for me too. Thanks