I've got a helper method which renders some html along with the required css and js links. I am simply concatenating all the html tags and returning the built string. The helper method is something like this:
function display_linkPreview($data = array())
{
$return = "<link rel=\"stylesheet\" class=\"cssStatics\" type=\"text/css\" href=".base_url()."assets/css/stylesheet.css\" />
<script type=\"text/javascript\" src=".base_url()."assets/js/linkPreview.js\" ></script>
<div>blah blah<div></div></div>";
return $return;
}
And this is the way I am going to render the outpt of display_linkPreview
in one of the views:
echo display_linkPreview($body);
The problem is that all the output of display_linkPreview
, including the <link>
and <script>
tags will be rendered in the middle of HTML page where I have called echo
. How can I modify display_linkPreview
to add css
and js
tags to the <head>
of html?