By Dan Silver on
Hello, i'm trying to add some css to my test module and I can't get it working. I have looked around but couldn't find any good resources. Right now it just shows text in the block without any formatting.
themepractice.info:
; $Id$
name = "Theme Practice"
description = "A practice module for themeing modules."
core = 6.x
php = 5.1
stylesheets[all][] = tp.css
themepractice.module:
function themepractice_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Theme Practice');
return $blocks;
case 'view':
$blocks['subject'] = t('Themeing Practice');
$blocks['content'] = themepractice_theme();
return $blocks;
}
}
function themepractice_theme() {
$module_path = drupal_get_path('module', 'Theme Practice');
$full_path = $module_path .'/tp.css';
drupal_add_css($full_path);
$name = "George";
$string = '<div id="name">' . t($name) . '</div>';
return $string;
}
tp.css:
#name {
font-style:oblique;
text-align: right;
font-size:20px;
}
Thank you for any help!
Comments
bad parameters
Hi,
Are you sure that the second parameter of drupal_get_path is correct ?
I think it should be the name of your module folder : "themepractice".
thanks
I changed everything to be "themepractice". Now i'm getting a white screen on everypage of the website.
The folder name is "themepractice". Here is a copy of the new "themepractice.module":
Have you tried adding it
Have you tried adding it through hook_init() to see if it shows up?
For error checking to find the faulty line and to make sure your path is correct you can try to print the path and just functions such as var_dump(), die() and if you have Devel installed, dsm(), dpr() while uncommenting lines that could cause errors if not correct.
To troubleshoot the WSOD
To troubleshoot the WSOD issue, edit the main drupal index.php and add these lines before the include of bootstrap.inc
Have you verified that tp.css is not being loaded or the CSS file is being included in the page source?
Focusing on Business Applications but heck we do anything Drupal
There is nothing with the
There is nothing with the code as you have shown it that would cause the WSOD. Try clearing the cache. Also, is there more code than you are showing us?
Finally this:
$string = '<div id="name">' . t($name) . '</div>';Is no good. You should never pass variables into the t() function. Values inside t() should always be constants. For something like someone's name, you would never pass it through the t() function.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.