I wan't to add bootstrap.css to a template in a custom layout.xml, this is my code:
view/frontend/web/css/bootstrap.css here is the css file
view/frontend/layout/pakke_trackshipment_info.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<!-- Here I have tried both methods but no one worked -->
<css src="Vendor_Pakke::css/bootstrap.css"/>
<css src="css/bootstrap.css" />
</head>
<referenceContainer name="content">
<block class="Vendor\Pakke\Block\TrackInfo\TrackingInfo" name="tracking_info" template="Vendor_Pakke::track_info.phtml"/>
<!--Magento\Framework\View\Element\Template-->
</referenceContainer>
</page>
Also I will add my controller code in case i'ts wrong. I'm practically sending $order_id
to the template and printing the template.
public function execute()
{
$order_id = $this->getRequest()->getParam("order_id");
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__(' heading '));
$block = $resultPage->getLayout()
->getBlock('tracking_info')
->setOrderId($order_id)
->toHtml();
$this->getResponse()->setBody($block);
}
The template shows the html correctly with the data that I'm passing to it, but the css never loads, it's just plain html.
Greetings!