Could you please help me, i'm trying to print a block of html code.

Im using a template file wid.tpl.php i need to pass some variables:

$htmlget = theme('wid',array('id'=> $id,'temp'=> $temp,'game'=> $game));

and this is my code on that file:

$list = get_defined_vars();

print "<style>
.Opta h2{background-color: #ff191e !important;}
<link rel='stylesheet' href='https://secure.widget.cloud.opta.net/v3/css/v3.football.opta-widgets.css'>
<script src='https://secure.widget.cloud.opta.net/v3/v3.opta-widgets.js'></script>
    var opta_settings = {
    subscription_id: 'bccfa17c076140fd251fc5edc10c4dc6',
    language: 'es_CO',
    timezone: 'America/Mexico_City'
 <div id='container-opta-all-widget'> 
        <opta-widget competition=". $idcompetition." season=". $temporada." match=". $idgame."></opta-widget>

but i need run that javascripts files v3.opta-widgets.js and that between <script> tags to add somethings to container-opta-all-widget tag

how can i do that


You should preprocess the template itself in template.php, and call drupal_add_js to add inline JS like that when you need it.


You can do the same with drupal_add_css too.

HTML code does not need to go within <?php ?> tags. Just write it as normal and inject your variables like <?php print $variable; ?>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.