7

I have tried to put this code in custom block with input formated to PHP code:

$settings = theme_get_settings('my theme');
if (!$settings[toogle_logo] = 0) {
  print '<img src="' . base_path() . $settings['logo_path'] . '" alt="my logo" />'; 
}

It doesn't work in Drupal 7.

  • 1
    Check out the delta blocks module – chrisjlee Oct 12 '12 at 20:51
11

theme_get_settings() was removed in Drupal 7. Instead, use theme_get_setting(). This works:

<?php

if (theme_get_setting('toggle_logo')) {
  $image = array(
    'path' => theme_get_setting('logo'),
    'alt' => 'my logo',
  );
  print theme('image', $image); 
}

?>

theme_get_setting() will get the current theme's setting, but if you want an arbitrary theme's setting, you can use the optional second parameter as described in the API docs. I used theme_image() to make it less fragile.

But if you can avoid the use of the PHP filter, you really should: consider creating a small custom module that creates a block with the code instead.

| improve this answer | |
4

One problem with your code is that you use =, not == in your if statement.

Sounds like a job for Blockify. And if you don't want to use "a whole module" just for that, you can see how it's done and use the correct snippet.

| improve this answer | |
  • Yes, this was one of the problems. – Ek Kosmos Mar 21 '11 at 12:24

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.