Raw Content data

Retrieving the raw, unrendered data of content-elements

In contrast to the example of how to retrieve rendered content elements let’s create an endpoint that returns the “raw” data from the table tt_content for a given uid:

<?php
namespace My\Extension\Api;

use Nng\Nnrestapi\Annotations as Api;
use Nng\Nnrestapi\Api\AbstractApi;

/**
 * @Api\Endpoint()
 */
class Content extends AbstractApi
{
  /**
   * @Api\Access("public")
   * @Api\Localize()
   *
   * @param int $uid
   * @return array
   */
   public function getRawAction( int $uid = null )
   {
      // Get raw data from table tt_content and include FAL-relations
      $data = \nn\t3::Content()->get( $uid, true );
      return $data;
   }
}

To see the results, send a GET request to:

https://www.mysite.com/api/content/raw/{uid}

Example result of what you get:

{
   "uid": 1,
   "pid": 2,
   "header": "My title",
   "bodytext": "<p>This is <a href=\"t3://page?uid=6\">link to a page</a></p>",
   "assets": [
      "uid": 14,
      "publicUrl": "fileadmin/path/to/image.jpg"
   ],
   ...
}