如何从后端/admin-panel管理drupal 7中的page- front.tpl.php图像


How to manage page--front.tpl.php images from back-end/admin-panel in 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中的图像,以及管理员如何从后端放置到该图像的链接。我怎么能做到呢?

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

然后你可以硬编码在你的模板文件中读取特定类型的节点,或者使用Views (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'是图像字段的名称。在编辑内容类型的字段时,可以添加和编辑图像字段的名称。请确保将字段类型设置为"Image"。