简体   繁体   English

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

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

I'm using Couch CMS ,and i made the header background an editable region,then when I change the image from the admin page the new image appear only in the home page although in the other pages i use this 我正在使用Couch CMS,并且将标题背景设置为可编辑区域,然后当我从管理页面更改图像时,新图像仅出现在主页中,尽管在其他页面中我使用了

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

the code in index.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(); ?>

the code in header.php 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(); ?>

why when i get the header page contents in other pages except index the image does not change?? 为什么当我在除索引之外的其他页面中获得标题页内容时,图像没有变化?

I think that You need to append Couch CMS's cms:editable to a regular html tag pair. 我认为您需要将Couch CMS的cms:editable附加到常规html标签对中。

Like so: 像这样:

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

You simply need to append a style="background-image: url("<cms:show header />");" 您只需要附加一个style="background-image: url("<cms:show header />");" to your main header container. 到您的主标头容器。

eg 例如

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

Specify the rest of the CSS in your main styles file. 在主要样式文件中指定其余的CSS。

You actually do not need to use the 'header' as a full-fledged template (because I don't think it is supposed to be accessed directly through a browser using its URL). 实际上,您实际上不需要将“标头”用作完整的模板(因为我不认为应该使用其URL直接通过浏览器对其进行访问)。 Instead, it should be converted into a 'snippet' that can then be included in the other templates. 相反,应该将其转换为“片段”,然后将其包含在其他模板中。

To do that, please create a text file named 'header.html' with the following contents and then place this file within the 'snippets' folder of your Couch installation (which appears to have been renamed as 'admin' in your case). 为此,请创建一个名为“ header.html”的文本文件,其中包含以下内容,然后将该文件放置在Couch安装的“ snippets”文件夹中(在您的情况下,该文件夹似乎已重命名为“ admin”)。 Please note that no <?php require_once('admin/cms.php'); ?> 请注意,没有<?php require_once('admin/cms.php'); ?> <?php require_once('admin/cms.php'); ?> or <?php COUCH::invoke(); ?> <?php require_once('admin/cms.php'); ?><?php COUCH::invoke(); ?> <?php COUCH::invoke(); ?> are required in snippets. <?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;
}

Next, in all your templates where you wish to include the header, use the following statement 接下来,在所有要包含标题的模板中,使用以下语句

<cms:embed 'header.html' />

So, for example, your index.php template would now become this - 因此,例如,您的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(); ?

Hope this helps. 希望这可以帮助。

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

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