繁体   English   中英

页眉背景图像在cms的所有页面中均未更改

[英]Header background Image does not change in all pages from cms

我正在使用Couch CMS,并且将标题背景设置为可编辑区域,然后当我从管理页面更改图像时,新图像仅出现在主页中,尽管在其他页面中我使用了

<?php echo file_get_contents("header.php");  ?>

index.php中的代码:

    <?php require_once('admin/cms.php'); ?>
    <cms:template title = 'English Home Page'>
    <cms:editable name='header' type='image' />
    </cms:template>
     <?php echo file_get_contents("header.php");  ?>
    <?php COUCH::invoke(); ?>

header.php中的代码

    <?php require_once( 'admin/cms.php' ); ?>
    .site-header {
        background-image: url("<cms:show header />");
        background-repeat: no-repeat;
        background-position: center;
        background-attachment: notdefined;
        background-clip: padding-box;
        background-size: cover;
        background-origin: padding-box;
    }

    <?php COUCH::invoke(); ?>

为什么当我在除索引之外的其他页面中获得标题页内容时,图像没有变化?

我认为您需要将Couch CMS的cms:editable附加到常规html标签对中。

像这样:

<div class="header-bg" style="background-image: url('<cms:show header />');"></div>

您只需要附加一个style="background-image: url("<cms:show header />");" 到您的主标头容器。

例如

<cms:editable name='header' type='image' style='style="background-image: url("<cms:show header />");'/>

在主要样式文件中指定其余的CSS。

实际上,您实际上不需要将“标头”用作完整的模板(因为我不认为应该使用其URL直接通过浏览器对其进行访问)。 相反,应该将其转换为“片段”,然后将其包含在其他模板中。

为此,请创建一个名为“ header.html”的文本文件,其中包含以下内容,然后将该文件放置在Couch安装的“ snippets”文件夹中(在您的情况下,该文件夹似乎已重命名为“ admin”)。 请注意,没有<?php require_once('admin/cms.php'); ?> <?php require_once('admin/cms.php'); ?><?php COUCH::invoke(); ?> <?php COUCH::invoke(); ?>段中必须包含<?php COUCH::invoke(); ?>

.site-header {
background-image: url("<cms:get_custom_field 'header' masterpage='index.php' />");
background-repeat: no-repeat;
background-position: center;
background-attachment: notdefined;
background-clip: padding-box;
background-size: cover;
background-origin: padding-box;
}

接下来,在所有要包含标题的模板中,使用以下语句

<cms:embed 'header.html' />

因此,例如,您的index.php模板现在将变为:

<?php require_once('admin/cms.php'); ?>
<cms:template title = 'English Home Page'>
    <cms:editable name='header' type='image' />
</cms:template>

<cms:embed 'header.html' />
<?php COUCH::invoke(); ?

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM