【问题标题】:TYPO3 get products per uid out of backendTYPO3 从后端获取每个 uid 的产品
【发布时间】:2021-08-30 07:39:59
【问题描述】:

我是 TYPO3 和 Fluid 的新手。我想通过一个按钮生成一个动态的PDF。

我的问题是我不知道如何使用他们的 uid 获取我的产品。

它们都有一个 uid。我的问题是如何使用流式代码在前端显示它们?

如果我尝试使用 cObject Records 访问产品数据,则会收到错误“表不存在”

所以我发现 cObject 使用了数据库,这就是我收到“表不存在”错误的原因

但这不是我想要的。我想从后端记录中取出数据。

打字稿:

lib.fluidLoadRecord = RECORDS
lib.fluidLoadRecord {
  source.data = current:1
  source.intval = 1
  dontCheckPid = 1
  tables = product
}

流体:

{f:cObject(typoscriptObjectPath: 'lib.fluidLoadRecord', data: '69')}

<!--<v:page.resources.fal table="product" uid="69">
<pdf:text>{product.description}</pdf:text>
</v:page.resources.fal>-->

任何帮助将不胜感激。

【问题讨论】:

    标签: typo3 fluid


    【解决方案1】:

    您确定该表名为product 而不是tx_product_domain_model_item。你可以例如检查输入字段 ProductSeries 的源代码,您会看到类似的内容

    data-formengine-input-name="data[be_groups][1][title]"
    

    在我的示例中,表格为be_groups


    对于渲染,您需要更多这样的代码

    lib.fluidLoadRecord = RECORDS
    lib.fluidLoadRecord {
      source.data = current:1
      source.intval = 1
      dontCheckPid = 1
      tables = tx_your_db_table_name
    
      conf.tx_your_db_table_name = COA
      conf.tx_your_db_table_name {
        10 = TEXT
        10 {
          field = producseries
          htmlspecialchars = 1
          wrap = <h1>|</h1>
      }
    }
    

    【讨论】:

    • 您好,感谢您的回答!我已经找到了解决方案。你是对的。我试图通过后端访问它,但这根本不可能。访问必须通过数据库表。我应该用解决方案回答我自己的问题吗?
    • 如果你找到了一个不错的解决方案,是的,也请添加它
    • 我添加了它。你能帮助我如何连接两个表并显示它们吗?
    【解决方案2】:

    因此,正如本文中已经提供的,这里是解决方案。 无法直接从后端访问数据。 只有通过数据库表才有可能。

    lib.fluidLoadRecord0 = RECORDS
    lib.fluidLoadRecord0 {
    source.data = current:1
    source.intval = 1
    dontCheckPid = 1
    tables = tx_bmyproducts_domain_model_product
    
    conf.tx_bmyproducts_domain_model_product = TEXT
    conf.tx_bmyproducts_domain_model_product.field = producseries
    }
    

    以及如何在 cObject 中使用它

    <f:cObject typoscriptObjectPath="lib.fluidLoadRecord0">69</f:cObject>
    

    如果你想加入一些表格并显示它们,你可以使用类似的东西。

    lib.productfamily = CONTENT
    lib.productfamily {
    table = tx_bmyproducts_domain_model_product
    select {
      uidInList = 69
      pidInList = 369
      selectFields = title
      join = tx_bmyproducts_domain_model_productfamily on 
             tx_bmyproducts_domain_model_productfamily.cruser_id = 
             tx_bmyproducts_domain_model_product.cruser_id
      where = tx_bmyproducts_domain_model_product.uid
      }
    
     renderObj = TEXT
     renderObj {
     field = title
      }
     }
    

    然后就可以用cObject显示数据了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-06
      • 2013-01-28
      • 2010-11-24
      • 2015-11-05
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多