By vsr on
I created a block template with this code.
<?php if ($block->subject): ?>
<div class="orangebar"><h2><?php print $block->subject ?></h2></div>
<?php endif;?>
<div class="content"><?php print $block->content ?></div>
</div>I created a CSS class
div.orangebar { background url(images/orangebar.png) 0 0 no-repeat; width: 100%; }
In the page code, I see the following, but the orange bar does not show.
<div class="orangebar"><h2>User-1</h2></div>
Can somebody please tell me what I am doing wrong. Thanks in advance your help.
Comments
not sure if the syntax u used
not sure if the syntax u used are wrong, but i will try ..
...
The above comment is actually not what to do, ideally PHP should be in HTML not the other way around.
The problem is not your PHP, its your CSS, you are missing a colon (:) after background.
div.orangebar { background : url(images/orangebar.png) 0 0 no-repeat; }
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Thanks
Thanks jmburnz. That fixed the problem.
what do u mean by "..PHP
what do u mean by "..PHP should be in HTML .."?
yes..i overlooked the ":"
...
In this first example notice how the HTML is embedded within the PHP print statement:
if ($block->subject) { print '<h2>' . $block->subject . '</h2>'; }Ideally you should avoid that in tpl files and write your PHP inside of the HTML, i.e.:
Notice how there is no HTML embedded within the PHP code, they are kept separate.
I generally believe that this is a Drupal convention although you are of course free to do what you want:)
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Did you try using Block theme
Did you try using Block theme module....as the name suggest you can theme any block as you want. Its really nice even i used it.
chetan