Project

General

Profile

Actions

Feature #68069

closed

Provide an API to get sys_categories of a given page ID

Added by Moritz Ahl over 9 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2015-07-13
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

Description

Currently, there seems to be no elegant way to retrieve sys_categories for a given page ID.
Usage example: In an extbase actionController, I want to retrieve Records which belong to the categorie(s) which is/are associated to the current Page ID. To archieve this, I need to be able to first read all categories which belong to a certain Page ID, and then get the corresponding records I'm interested in.

I have found this doc:
http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Categories/Index.html

...but it only describes how to get records of a certain category, not the other way round. Of course I could write my own DB statement. But IMO, getting the sys_categories for a page is a basic thing that should made easy by providing an API method.

For example:
Input: page UID
Output: array of category UIDs or comma-separated.

Actions #1

Updated by Alexander Opitz about 9 years ago

  • Category set to Extbase
  • Target version changed from 6.2.15 to 7.5
Actions #2

Updated by Benni Mack about 9 years ago

  • Target version changed from 7.5 to 8 LTS
Actions #3

Updated by Riccardo De Contardi over 7 years ago

  • Target version changed from 8 LTS to 9.0
Actions #4

Updated by Susanne Moog almost 7 years ago

  • Target version deleted (9.0)
Actions #5

Updated by Stefan Froemken over 1 year ago

  • Status changed from New to Closed

Hello,

thank you for that issue ticket. I have just tried to solve such a query with extbase and that's my result:

public function findCategoriesWithRelationOnSamePage(): QueryResultInterface
{
    $query = $this->createQuery();

    return $query
        ->matching(
            $query->logicalAnd(
                $query->logicalNot($query->equals('categories.uid', null)),
                $query->equals('categories.pid', $GLOBALS['TSFE']->id)
            )
        )
        ->execute();
}

It matches only records which have categories assigned in general. Further it selects just categories from current page.

I will close the ticket now. If you feel this is the wrong decision, let me know, and I will re-open it.

Stefan

Actions

Also available in: Atom PDF