【问题标题】:Building a slideshow with the jCarousel module使用 jCarousel 模块构建幻灯片
【发布时间】:2011-06-20 14:46:48
【问题描述】:

我正在使用 jCarousel 构建以块显示的幻灯片。内容类型具有图像上传字段,这些图像将显示在轮播中。我希望每个节点在轮播中都有不同的图像。在视图中,我按类型定义了过滤器。但这会从每个节点获取所有图像。我该如何解决这个问题?

【问题讨论】:

    标签: drupal slideshow drupal-jcarousel


    【解决方案1】:

    您想要在特定页面上的图像是否通过该页面上传?

    如果是这样,您可以使用 Node:NID 参数。

    在“如果参数不存在时采取的措施:”下

    勾选“提供默认参数”

    然后是“来自 URL 的节点 ID”

    【讨论】:

    • 非常感谢!这解决了我的问题。 :) 还有一件事。如何单独设置幻灯片的样式。例如,在一种类型的页面上,我希望幻灯片的宽度为 960 像素,而在另一种类型的页面上为 600 像素。
    • 如果你的 template.php 提供了 body 类,而你的 page.tpl.php 调用了它们,那么你就有了 .node-type-(nodetype) 类来帮助你按节点类型进行主题化。
    【解决方案2】:

    这里是关于 template.php 注释的更多信息:

    在page.tpl.php中添加

    <body class="<?php print $body_classes; ?>">

    在template.php中,添加

    function phptemplate_preprocess_page(&$vars, $hook) {
        // Classes for body element. Allows advanced theming based on context
        // (home page, node of certain type, etc.)
        $body_classes = array($vars['body_classes']);
        if (!$vars['is_front']) {
    
          // Add unique classes for each page and website section
          $path = drupal_get_path_alias($_GET['q']);
          list($section, ) = explode('/', $path, 2);
          $body_classes[] = phptemplate_id_safe('page-' . $path);
          $body_classes[] = phptemplate_id_safe('section-' . $section);
          if (arg(0) == 'node') {
            if (arg(1) == 'add') {
              if ($section == 'node') {
                array_pop($body_classes); // Remove 'section-node'
              }
              $body_classes[] = 'node-add'; // Add 'node-add'
            }
            elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
              if ($section == 'node') {
                array_pop($body_classes); // Remove 'section-node'
              }
              $body_classes[] = 'node-' . arg(2); // Add 'node-edit' or 'node-delete'
            }
          }
        }
        $vars['body_classes'] = implode(' ', $body_classes); // Concatenate with spaces
      }
    
      function phptemplate_id_safe($string) {
        if (is_numeric($string{0})) {
          // If the first character is numeric, add 'n' in front
          $string = 'n'. $string;
        }
        return strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string));
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      相关资源
      最近更新 更多