Issue Bug Closed

#100970in USER / USER_INT the calling CE isn't exposed

David Bruchmann 06/07/23, 09:26 updated 10/02/26, 07:24

Description

While writing a USER / USER_INT class it seems impossible to know which element was called to trigger the execution.
So all elements have to be crawled and likely the register of TSFE be filled with elements that have been processed, but there isn’t any way to get a reliable hint about the calling element.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 11

  1. Oliver Hader commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2023-06-07T09:56:42+00:00" > 06/07/23, 09:56 </span>

    Can you please give more context or an example?

  2. David Bruchmann commented <span data-processor="relativetime" data-value="2023-06-07T10:09:05+00:00" > 06/07/23, 10:09 </span>

    TSFE->cObj is just the page record, so it’s not useful here.

    An example could be that headline and content of header and bodytext should be available in the class.
    So I’ve to retrieve the fields, which should be in my opinion already available in TSFE->cObj->data.
    Never having an uid at least it’s not possible to know which record to query.
    So it seems to be required to query all applying records and to process them systematically, also using a register property of TSFE, so that a CE isn’t processed twice.

  3. Stefan Bürk commented <span data-processor="relativetime" data-value="2023-06-07T10:59:21+00:00" > 06/07/23, 10:59 </span>

    Not getting this, this should basically works (not tested, but from the code).

    In your user function class, you should access to the parent information with:

    $parentData = $this->cObj->parentRecord['data'] ?? null;
    $parentCurrentRecord = $this->cObj->parentRecord['currentRecord'] ?? null;

    If I remember right, you should have a “setContentObjectRenderer()” method
    in your user method to as public $cObj setting is deprectated.

    UserInt gehts serialized/deserialized but this information should be existing.

    And trying to work with TSFE->cObj looks scary. You should more operate on the
    current contentObject and the parent.

    Maybe you can provide some code what you are trying to solve ?

  4. David Bruchmann commented <span data-processor="relativetime" data-value="2023-06-07T11:25:56+00:00" > 06/07/23, 11:25 </span>

    the method begins like this

        public function start(string $content, array $conf): string
        {
            if (!is_object($this->getTsfe())) {
                return $content;
            }
            $cObj = $this->getTsfe()->cObj;
            $parentData = $cObj->parentRecord['data'] ?? null;
            $parentCurrentRecord = $cObj->parentRecord['currentRecord'] ?? null;
            ...

    and actually I want to merge TypoScript with json (we chatted about the json, Stefan).
    But that’s coming afterwards,first I want to get the cObj though.

  5. David Bruchmann commented <span data-processor="relativetime" data-value="2023-06-08T09:58:56+00:00" > 06/08/23, 09:58 </span>

    Throughout the classes TypoScriptFrontendController and all related classes it’s stated that properties are assigned if the record is of type CONTENT or RECORD, but USER / USER int isn’t mentioned at all. So actually the behavior is at least consistent to the internal documentation.
    Nevertheless it’s not sufficient.

    Example copied from the code in TypoScriptFrontendController:

        /**
         * This is set to the [table]:[uid] of the latest record rendered. Note that
         * class ContentObjectRenderer has an equal value, but that is pointing to the
         * record delivered in the $data-array of the ContentObjectRenderer instance, if
         * the cObjects CONTENT or RECORD created that instance
         */
        public string $currentRecord = '';
  6. Stefan Bürk commented <span data-processor="relativetime" data-value="2023-06-10T15:45:11+00:00" > 06/10/23, 15:45 </span>

    Please provide some more context and information. For example, you could
    add the used TypoScript as example. Not fully getting what you are trying
    to really do here and why the parent record is needed or not.

    Would be nice if you could provide something which can be used to reproduce
    this easily and debug this in some way. Cannot get your “configuration” used
    and hitting this “issue”. That would minimize the time to get a reproducable
    state locally running instead of trying to reproduce this with a lot of guessing.

    So, please provide an example (TypoScript etc) needed to get/reproduce this.

  7. David Bruchmann commented <span data-processor="relativetime" data-value="2023-06-10T16:11:10+00:00" > 06/10/23, 16:11 </span>

    Hi STefan,

    thanks for having a look at it again.
    I think the information you ask for is not relevant, I described it already very clear.
    The TypoScript is very simple:

    asd = USER
    asd.userFunc = \XYZ\Abc\....

    If you think you can’t do anything with my descriptions, just close this issue.
    I solved it for the moment with a loop and overwriting TSFE myself. It might not be 100% correct but it’s working.

  8. David Bruchmann commented <span data-processor="relativetime" data-value="2023-12-05T08:19:50+00:00" > 12/05/23, 08:19 </span>

    I added one line (the first one below) and that’s solving my case of much headaches, as I’ve the required data available.
    Like this I can access anything that is stored in the CE record.
    Without my change it’‘s almost impossible to determine from which record the call is coming, if several USER elements are on one page.

    Class: TYPO3\CMS\Frontend\ContentObject\UserContentObject

            $conf['_data_'] = $this->cObj->data;
            $tempContent = $this->cObj->callUserFunction($conf['userFunc'] ?? '', $conf, '');
  9. Georg Ringer commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-10-02T07:21:14+00:00" > 10/02/26, 07:21 </span>

    hey David,

    as nothing happened in the last 3 years and you got a solution. I will take your suggestion and close the issue – also to cleanup forge a bit.
    hope this is ok for you as well!

  10. David Bruchmann commented <span data-processor="relativetime" data-value="2026-10-02T07:24:58+00:00" > 10/02/26, 07:24 </span>

    Hey Georg,

    actually that’s a pity, but it seems I’ve to come forward with a patch by myself, not only concerning this issue.

    Beside of that I still have always the option to patch installations.