vhs icon indicating copy to clipboard operation
vhs copied to clipboard

v:content render not working in v11 ?

Open Seitenmacher opened this issue 2 years ago • 5 comments

Seems like v:content.render doesn't render anything right now ? Installation is based on flux with custom elements, but v:content.render doesn't render a content element by colPos/column and also not rendering a content element by using <v:content.render contentUids="{0: 1}"/>

Not getting any output in frontend - anybody else has this issues ?

Same workflow in v10 is working perfect.

Seitenmacher avatar Jun 03 '22 11:06 Seitenmacher

I tested this just now on v11 and it appears to be working like it should. Is there anything special about the content/column setup, e.g. not in the default language, fallback rendering mode, content sliding, workspace active or other? Shot from the hip: did you perhaps forget to install the fluid_styled_content extension (or another "content rendering" extension that provides basic tt_content TS setup)?

NamelessCoder avatar Jun 16 '22 11:06 NamelessCoder

having the same issue without flux. fluid_styled_content is installed and working

the content element with uid: 3 exists.

<v:content.render contentUids="{0: 3}"/>

PHP Warning: Undefined array key "tt_content:3" in /var/www/html/public/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 222

jonashaas avatar Jun 29 '22 09:06 jonashaas

Confirm this bug, this is a php 8.0/8,1 behaviour:

if (0 < $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']]) {

should be

if (0 < isset($GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']]) ? $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']] : 0) {

ecosmox36 avatar Jul 18 '22 13:07 ecosmox36

Can confirm.

if (0 < $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']] ?? 0) {

... should also do the job.

mediaessenz avatar Jul 27 '22 13:07 mediaessenz

I can confirm this bug on TYPO3 11.5.14, PHP 8.0.22

the code from ecosmox36 worked here.

if (0 < isset($GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']]) ? $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']] : 0) {

got errors with if (0 < $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']] ?? 0) {

thanks for your input!

dirnbauer avatar Aug 24 '22 06:08 dirnbauer

I can confirm this bug also with PHP 8.1 TYPO3 11.5.17 VHS 6.1.2

hhchrizzo avatar Nov 07 '22 11:11 hhchrizzo

confirm this as well using:

  • PHP 8.0.24
  • TYPO3 11.5..18
  • VHS 6.1.2

the code from @ecosmox36 worked for me as well.

nabossha avatar Nov 08 '22 17:11 nabossha

Same problem with PHP 8.0.21 T3 11.5.19 VHS 6.1.2

With PHP 7.4 no problems

t3touch avatar Nov 16 '22 20:11 t3touch

@NamelessCoder can also confirm the problem with PHP 8.1

josefglatz avatar Nov 25 '22 14:11 josefglatz

Fixed via https://github.com/FluidTYPO3/vhs/commit/f76456a340b05d14ebc720c92adaf3dd34f93984#diff-943e93d35eada4f1bef5a2f95f81740f338fde28a0431fc9d733d1a106c1d51bL183

NamelessCoder avatar Nov 25 '22 15:11 NamelessCoder

I got another unexpected exception in line 239: PHP Warning: Undefined array key "tt_content:2835" in /###/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 239

238        if (false === empty($parent)) {
239            ++$GLOBALS['TSFE']->recordRegister[$parent];
240        }

I added if (isset($GLOBALS['TSFE']->recordRegister[$parent])) before lines 239 and 245

TYPO3 11.5.22 VHS 6.1.3 PHP Version 8.0.27

ako-3004 avatar Feb 07 '23 10:02 ako-3004

I'm getting the same same exception from line 239 after upgrading to PHP 8.

PHP Warning: Undefined array key "tt_content:38796" in /srv/www/public/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 239

TYPO3 11.5.24 VHS 6.1.3 PHP 8.1.15

RKlingler avatar Feb 16 '23 10:02 RKlingler

compare to the other issues, "PHP Warning: Undefined array key"

you need to fix the parent too.

line ~235: old: ++$GLOBALS['TSFE']->recordRegister[$parent];

new:

        if (false === empty($parent)) {
            if (0 < isset($GLOBALS['TSFE']->recordRegister[$parent]) ? ++$GLOBALS['TSFE']->recordRegister[$parent] : 0) {
                return null;
            }
        }

MarcoHaase avatar Jul 12 '23 10:07 MarcoHaase

Still got the error PHP Warning: Undefined array key "tt_content: ..." inside an gridelements Template.

# Flyout Sidebar
# TSconfig: 47.flexformDS = FILE:typo3conf/ext/my/Resources/Private/Flexforms/Ext/Grid_Elements/flyout_sidebar.xml
47 < lib.gridelements.defaultGridSetup
47 {
    cObject = FLUIDTEMPLATE
    cObject {
        file = {$templatePath}Ext/Grid_Elements/flyout_sidebar.html
    }
}

inside flyout_sidebar.html I'am calling:

<v:content.render contentUids="{0: 1764}" ></v:content.render>

In my partial Footer.html the same line of code is working.

cmichael-de avatar Aug 23 '23 18:08 cmichael-de

the important part of your PHP error is the line number. Please give me full error message and --> Did you fix AbstractContentViewHelper.php like I wrote?

btw: it is easy to handle these PHP errors. you need to check first, if array key exists. if not return defined value. but no problem. I need line and please quote 5 lines above and after here of your AbstractContentViewHelper.php

MarcoHaase avatar Aug 23 '23 18:08 MarcoHaase

PHP Warning: Undefined array key "tt_content:8393" in /www/htdocs/blablabla/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 239

No I did not changed anything in AbstractContentViewHelper.php.

I wrote my own little Viewhelper instead:


<?php
namespace Vendor\Yourext\ViewHelpers;

use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Frontend\ContentObject\RecordsContentObject ;


class ContentrenderViewHelper extends AbstractViewHelper {

    private $recordscontentobject;

    public function __construct(RecordsContentObject $recordscontentobject)
    {
        $this->recordscontentobject = $recordscontentobject;
    }

    /**
     * Arguments Initialization
     */
    public function initializeArguments() {
        $this->registerArgument('uid', 'int',  'Uid of an content element', TRUE);
    }

    /**
     * Parse content element
     *
     * @param  int     UID des Content Element
     * @return string  Geparstes Content Element
     */
    public function render() {
        $conf = array( // config
            'tables' => 'tt_content',
            'source' => $this->arguments['uid'],
            'dontCheckPid' => 1
        );
        return $this->recordscontentobject->render($conf);
    }
}

Works also in gridelements Templates like this:

<bla:Contentrender uid="1764" ></bla:Contentrender>

cmichael-de avatar Aug 23 '23 18:08 cmichael-de

This is line 239 in dev-development: https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Content/AbstractContentViewHelper.php#L239C63-L239C63

That code would not raise the error in question. And the statement that might raise the error is guarded by an isset() check.

Please make sure you verify whether the issue exists in dev-development before you report it. That branch is always the most current development state and if a bug does not exist in there, it is already solved and will be included in the next release.

NamelessCoder avatar Aug 23 '23 19:08 NamelessCoder

common! you fixed it at Jul 12 --> https://github.com/FluidTYPO3/vhs/commit/6f8c743e2e078afa0bed3c0511ec87dad28365fd I wrote it at Jul 12 --> https://github.com/FluidTYPO3/vhs/issues/1787#issuecomment-1632223615

@cmichael-de: please get the last version of vhs. and it is important that you post here from the affected PHP script /www/htdocs/blablabla/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php the lines that are around the affected line so that one knows which code snippet it is. So in that case 235-245 would be very helpful.

@cmichael-de: Hol Dir die neuste VHS Version. Sie haben den bug gefixt seit 12. Juli https://github.com/FluidTYPO3/vhs/commit/6f8c743e2e078afa0bed3c0511ec87dad28365fd und es ist wichtig, dass du hier aus dem betroffenen PHP script /www/htdocs/blablabla/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php die zeilen postest, die um die betroffene zeile herum liegen, damit man weiß um welchen code snippet es sich handelt. also in dem fall wäre 235-245 sehr hilfreich.

MarcoHaase avatar Aug 23 '23 19:08 MarcoHaase

Yes it is working in development branch.

@MarcoHaase Thanks for your hints!

cmichael-de avatar Aug 24 '23 20:08 cmichael-de