문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top