FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

v:content render not working in v11 ? #1787

Closed Seitenmacher closed 1 year ago

Seitenmacher commented 2 years ago

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

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

Same workflow in v10 is working perfect.

NamelessCoder commented 2 years ago

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)?

jonashaas commented 2 years ago

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

ecosmox36 commented 1 year ago

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) {

mediaessenz commented 1 year ago

Can confirm.

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

... should also do the job.

dirnbauer commented 1 year ago

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!

hhchrizzo commented 1 year ago

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

nabossha commented 1 year ago

confirm this as well using:

the code from @ecosmox36 worked for me as well.

t3touch commented 1 year ago

Same problem with PHP 8.0.21 T3 11.5.19 VHS 6.1.2

With PHP 7.4 no problems

josefglatz commented 1 year ago

@NamelessCoder can also confirm the problem with PHP 8.1

NamelessCoder commented 1 year ago

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

ako-3004 commented 1 year ago

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

RKlingler commented 1 year ago

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

MarcoHaase commented 12 months ago

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;
            }
        }
cmichael-de commented 10 months ago

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.

MarcoHaase commented 10 months ago

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

cmichael-de commented 10 months ago

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>

NamelessCoder commented 10 months ago

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.

MarcoHaase commented 10 months ago

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.

cmichael-de commented 10 months ago

Yes it is working in development branch.

@MarcoHaase Thanks for your hints!