English 中文(简体)
根据用户选择情况改变博士网页的背景形象......
原标题:Changing background image of a Drupal page based on user s selection...?

我试图让我的用户能够改变一个网页上所用的背景形象。

背景图象清单将是一个小数,但实际变化不大。

我认为,我可以添加几个分类术语......每个背景类别......在阅读该页时,哪一个等级适用于正体。

这样做是否可行,如果是,我会怎样做?

增 编

Sam

问题回答

<>strong>EDIT:在澄清我对问题的误解后订正答案

如果要按(node)页界定背景形象,那么你通过像正确途径那样的滑油处理。 为了向社会保障局提供这些条件,最容易的方法是只把产出/使用作为代号(tpl.php)文档中的班级,在这些地方,你可以直接查阅<代码>Node。 但是,在这种情况下,他们被掩埋在最后标记的中间,因此很难加以适当使用。

为了在<代码>上添加这些字句: 页: 1

function yourModuleOrTheme_preprocess_page(&$vars) {
  // Add classes for body element based on node taxonomy
  // Is this a node page?
  if ( node  == arg(0) && is_numeric(arg(1))) {
    // Yes, extract wanted taxonomy term(s) and add as additional class(es)
    $node = node_load(arg(1));
    $background_vid = yourFuntionToGetTheBackgroundVocabularyId(); // Could be hardcoded, but better to define as variable
    $terms = $node[ taxonomy ][$background_vid];
    foreach ($terms as $tid => $term) {
      // NOTE: The following assumes that the term names can be used directly as classes.
      // You might want to safeguard this against e.g. spaces or other invalid characters first.
      // Check the zen_id_safe() function for an example (or just use that, if zen is always available)
      $vars[ body_classes ] .=     . $term;
    }
  }
}

注:未经测试的法典可能包含打字和其他监督。


(Original answer before edit - based on a misunderstanding of the OPs intent, left her in case other misunderstand it as well :)
The basic idea sounds feasible, but I d suggest a minor variation:

由于您希望每个用户都能调整环境,因此,你们不得不跳跃到一些灯光上,使用户能够用经济术语打上标签。 我认为,仅仅使(核心,但选择)>引人注目的模块,并在这里召集一个背景领域(类型清单选择)。 现场将张贴在用户网页上(如果你给出一个类别,则在该网页上有一个单独的表格),而用户选择则可以较容易地从代码上获得,例如,为网页模板选取一个类别:

global $user;
// NOTE: The following call would be the explicit way,
// but usually the profile fields get added to the $user object
// automatically on user_load(), so you might not need to call it at all,
// extracting the values directly from the $user object instead
$profile = profile_load_profile($user);
$background = $user->profile_background




相关问题
Drupal Multi-language: Simple strings not translated

I m adding additional languages to a Drupal site that I m building. Getting the translation of content working is fairly easy using the Internationalisation module. Yet, simple things such as date ...

Setting up a WYSIWYG editor for Drupal site users [closed]

Looking through the Drupal contrib modules, and after a few Google searches, it becomes evident that there are any number of choices and combos available to set up a WYSIWYG editor in Drupal. I m ...

Change size of user/password login box

I don t know how to change the size of the login username/password boxes on the drupal site that I m trying to build. I m stumbling through the theming, and don t know where to find the file that ...

How does Drupal provide an edit/review/publish model?

How does Drupal support a means to update and review a website before it is published? Does it only allow you to preview a page at a time before you publish it or is there a way to create a site ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

Has anyone checked out Drupal 7? [closed]

Has anyone checked out a copy of Drupal 7 yet? What do people think? I m pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure. Do ...

热门标签