是否可以用错字写一个特定的查询 [英] Is it possible to write a specific query in typoscript

查看:83
本文介绍了是否可以用错字写一个特定的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题似乎微不足道,很抱歉!我目前正在学习typo3和typoscript.我想创建一个带有动态背景图像的模板.该图像存储在目录中.我想从表tt_content获取图像名称.但是,这种工作方式使我有些困惑,而且我不知道我的看法是否正确.

my question may seem trivial, sorry if it is! I am currently learning typo3 and typoscript. I want to create a template with a dynamic background image. This image is stored in a directory. I would like to get the image name from the table tt_content. However, the way this works confuses me a bit and i don't know if my take on it is the right one.

代码如下:

20 = CONTENT
20.table = tt_content
20.select{
    where = pid = 79
}
20.headerImagePath = COA
20.headerImagePath {
    10 = TEXT
    10.stdWrap.field = image
    10.stdWrap.wrap = <div class="background-media" style="background-image: url('|'); background-repeat: no-repeat; background-size: cover; background-attachment: fixed; background-position: 50%;" data-start="background-position:50% 50%"
                            data-70-top-bottom="background-position:50% 70%">
                      </div>
}

我想将有关图像的信息(代码中的div部分)存储在变量中,并将其放入模板中.我的代码的模板部分如下所示:

I'd like to store the information about the image (the div part in the code) in a variable and put it into my template. The template part of my code looks like this:

<f:format.raw>{headerimage}</f:format.raw>

<f:cObject typoscriptObjectPath="headerimage" />

所以我的问题是,我从数据库中选择事物并将其存储到变量中的方式正确吗?我在模板中调用它们的方式正确吗?如果上述方法可以工作,但我有一些小错误,这是一种好的做法还是应该以其他方式做事?

So my question would be, is the way i am selecting things from the database and storing into a variable correct and is the way i am calling them in the template correct? If the way above should work but i have some little errors, is it good practice or should i do things differently?

亲切的问候

阿迪

推荐答案

您的代码段无效,因为您的结构非常错误.

your snippet will not work, because your structure is very wrong.

20.headerImagePath = COA

您尝试在上创建一个新的内容对象阵列 内容对象.

you try to create a new CONTENT OBJECT ARRAY on a CONTENT OBJECT.

20 = CONTENT

这不起作用.

但是CONTENT对象具有名为renderObj的属性.

But the CONTENT Object has a property called renderObj.

看下面的例子:

尝试这样:

lib.headerImagePath = CONTENT
lib.headerImagePath {

    # first call the content you need
    table = tt_content
    select {

        # Add your colPos
        # In this example i store my header image in colpos 9
        where = colPos = 9

        # PID from current field or define your own
        # pidInList = 123 
        pidInList.field = uid

        languageField = sys_language_uid
    }

    renderObj = COA
    renderObj {

        # FILES object was introduced in TYPO3 6.x
        10 = FILES
        10 {

            # Set a reference to let the file object know, where we will get the images
            references {
                table = tt_content
                uid.field = uid
                fieldName = image
            }

            # make sure we only get the first image in set
            maxItems = 1

            renderObj = COA
            renderObj {

                # We only need the url and not the complete image. So we need a IMG_RESOURCE and not an IMAGE Object
                10 = IMG_RESOURCE
                10 {

                    stdWrap {
                        wrap = <div class="background-media" style="background-image: url('|'); background-repeat: no-repeat; background-size: cover; background-attachment: fixed; background-position: 50%;" data-start="background-position:50% 50%" data-70-top-bottom="background-position:50% 70%"></div>
                        required = 1
                    }

                    # Import file from current object
                    # and treat the id as a reference (TYPO3 File Abstraction Layer)
                    file {
                        import.data = file:current:uid
                        treatIdAsReference = 1
                    }


                }

            }

        }

    }

}

也请看以下示例:

在这里,它们直接从页面属性中的MEDIA元素获取标题图像:

Also look at this examples:

Here they get the header image directly from the MEDIA Element in the page properties:

http://wiki.typo3.org/TypoScript_Header_Image

这篇关于是否可以用错字写一个特定的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆