Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top