BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Document content export #113

Closed ascheider closed 1 year ago

ascheider commented 1 year ago

Is there any possibility to export document content from pimcore via api? For example i have area bricks where i can input text or html code via wysiwyg, after that i want to embed the rendered document content in third party application via data director api. I don't see Pimcore documents in Source data type selection. Thanks!

BlackbitDevs commented 1 year ago

I don't see Pimcore documents in Source data type selection.

This is because I wanted to simplify UI: Export type "Pimcore objects" can be used to export data objects, documents and assets (actually Pimcore elements would be correct here). Please select Document as Source data class in this case.

To get the rendered HTML of the document you can use callback function

$document = \Pimcore\Model\Document::getById({{ DOCUMENT ID }});
$html = \Pimcore\Model\Document\Service::render($document);
return $html;

If you want to get HTML with absolute URLs (for images, CSS etc.), add

$html = \Pimcore\Helper\Mail::setAbsolutePaths($html, $document, \Blackbit\DataDirectorBundle\lib\Pim\Helper::getHostUrl());`

To make this even easier, I will add a data query selector convenience helper, so that you can simply add html as raw data field data query selector for dataports with source data class Document...

ascheider commented 1 year ago

@BlackbitDevs Thanks for the reply, works fine 👍 Yes agree Pimcore Elements would be better name here.

BlackbitDevs commented 1 year ago

Yes agree Pimcore Elements would be better name here.

Just renamed it in 3.5