如何在drupal 7中管理来自后端/管理面板的页面 - front.tpl.php图像

时间:2014-07-23 20:15:37

标签: php drupal drupal-7

我正在drupal 7的网站上工作,我在page--front.tpl.php创建了一个主页,Static Html与下面的代码一样,

<div class="col-sm-8 col-xs-24 botmboxes">
              <div class="row">
                <div class="boxbotmimg">
                  <img class="img-responsive" src="./sites/all/themes/korhanifashion/images/PlasticRug-Boat.png">
                  <span class="hovblck"></span>
                </div>
                <div class="botboxhov">
                  <a href="<?php print $front_page; ?>limited_offers">
                    <img class="bbres" src="./sites/all/themes/korhanifashion/images/limroffer.png"></a>
                </div>
              </div>
            </div>
            <div class="col-sm-4 col-xs-24 botmboxes botboxthree">
              <div class="row">
                <div class="boxbotmimg">
                  <img class="img-responsive" src="./sites/all/themes/korhanifashion/images/AnchorLine_BLCR_HI.png">
                  <span class="hovblck"></span>
                </div>
                <div class="botboxhov">
                  <a href="https://www.facebook.com/KORHANIhome">
                    <img class="bbres" src="./sites/all/themes/korhanifashion/images/fusonfbok.png"></a>
                </div>
              </div>
            </div>

我想从后端管理这些图像,即Admin-panel。因此,管理员可以更改Admin-panel中的图像,以及管理员如何从后端添加指向该图像的链接。 我怎么能这样做? 在此先感谢

1 个答案:

答案 0 :(得分:0)

我通常通过创建自定义内容类型(https://www.drupal.org/node/306792)来解决类似问题(自定义动态主页内容)。

然后您可以硬编码以读取模板文件中特定类型的节点或使用视图(https://www.drupal.org/project/views)。

添加了示例代码:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'home_image')
      ->entityCondition('status', 1);
$result = $query->execute();

if (isset($result['node'])) {
    $nodes = node_load_multiple(array_keys($result['node']));
    foreach ($nodes as $node) {
        $img_url = file_create_url($node->field_image['und'][0]['uri']);
    }
}

在上面的代码中,'home_image'是您创建的内容类型的名称,'field_image'是图像字段的名称。编辑内容类型的字段时,可以添加和编辑图像字段的名称。请务必将字段类型设置为“图像”。

相关问题