url stringlengths 50 196 | text stringlengths 3 17.2k | heading stringlengths 2 103 | embeddings list |
|---|---|---|---|
https://pimcore.com/docs/platform//Pimcore/Documents#document-types | Document Types
Pimcore offers different types of documents and each of them offers functionality specific for the intended use-case.
Type
Description
Page
Represents a typical web-page, the path in the tree is equal to the address in the browser.
Snippet
Makes it easier to extract often used contents into reusable containers. Can be embedded in pages or nested into other snippets.
Link
A simple web-link to be used in navigation.
Email
A document like the page, but with special functionality for transactional emails.
Hardlink
Create links to other document structures and reuse them within a different structure / context. (see Hard link)
Folder
Just like the folders you know from your local filesystem.
| Document Types | [
0.06738895177841187,
-0.43021199107170105,
-0.14389042556285858,
0.18685972690582275,
-0.09712116420269012,
-0.030161071568727493,
-0.06482839584350586,
0.04607031121850014,
-0.29632413387298584,
0.120372474193573,
-0.18017278611660004,
0.2870247960090637,
0.000646736822091043,
0.556232035... |
https://pimcore.com/docs/platform//Pimcore/Documents#document-configuration | Document Configuration
Many documents types are tight to the MVC and therefore they need a underlying controller/action and a template.
They are directly specified in the document settings in the admin interface:
Not all of them are necessary, the table below shows which configurations are possible:
Type
Controller
Template
Description
1
X
The specified controller/action is executed. If the action returns a response object, it is used for rendering.
2
X
X
Same as above but the template specified is rendered and not the auto-discovered template (only if action does not return a response).
3
X
Renders the template with the default controller/action, this is practical if there is only templating stuff.
Pimcore is shipped with a default controller containing a default action, which is called when only a template is given to the document.
You can set a default module/bundle, controller and action in the symfony configuration:
pimcore:
documents:
default_controller:App\Controller\DefaultController::defaultAction
| Document Configuration | [
-0.14998629689216614,
-0.46380242705345154,
0.031274907290935516,
-0.03245094045996666,
-0.01678246445953846,
-0.2390321046113968,
0.1607239991426468,
0.3533884286880493,
-0.22329792380332947,
0.212413027882576,
-0.02261451818048954,
0.3519919514656067,
0.22619307041168213,
-0.008627764880... |
https://pimcore.com/docs/platform//Pimcore/Documents#properties | Properties
Properties are very powerful in combination with documents.
Below, you can find some examples where properties can be very useful for the use with documents.
Navigation - If you build the navigation based on the document-tree, sometimes you need special settings for the frontend, like separators or highlightings.
Header Images - Often there are header images on a website, if you don't want to define it for every page, you can use properties with inheritance. Then you can define a default one at the root document, and overrule this on a deeper level in the tree structure.
Sidebars - You can easily manage visibility of sidebars in specific documents.
SEO - It's also possible to use properties for SEO. It's very painful to define a nice title and description for every page on your site, with properties this is not necessary (inheritance).
Protected Areas - Closed user groups
Change the appearance of the website depending on the properties (eg. micro-sites, nested sites)
Mark them for some automated exports (PDF, RPC's, …)
As you can see there are really useful cases for properties, feel free to use them for whatever they seem to be useful. | Properties | [
-0.04319872707128525,
0.014401890337467194,
-0.2413991540670395,
-0.05189651623368263,
0.03890509903430939,
-0.024038799107074738,
-0.055221665650606155,
0.29502072930336,
-0.28015580773353577,
0.218484565615654,
0.04108869284391403,
0.1103520616889,
0.18725226819515228,
-0.008621564134955... |
https://pimcore.com/docs/platform//Pimcore/Documents#a-few-facts | A Few Facts
Documents follow the MVC pattern; therefore, Pimcore requires that there is at least one controller with an action and a template file.
Pimcore comes with a DefaultController containing a defaultAction and a template file.
Because of the MVC architecture, there is a clear separation between your data, the functionality and the templates.
Templates for Pimcore are created with Twig.
As the templates are written in Twig, there is a clear separation of logic (controllers) and design (view / template).
| A Few Facts | [
0.037105243653059006,
-0.4945410192012787,
-0.05134841427206993,
0.15610761940479279,
-0.07358582317829132,
-0.3327164351940155,
0.05655079707503319,
0.013507199473679066,
-0.32090091705322266,
0.16235697269439697,
-0.06496398895978928,
0.44488081336021423,
0.08455173671245575,
0.120461679... |
https://pimcore.com/docs/platform//Pimcore/Documents#create-your-first-document | Create Your First Document
Working with documents is described in detail in our Create a First Project manual. | Create Your First Document | [
-0.015185906551778316,
-0.11422265321016312,
-0.25179702043533325,
-0.1520465761423111,
-0.1292259246110916,
-0.07414867728948593,
0.2120155394077301,
0.08004461228847504,
-0.2026665061712265,
0.3696068525314331,
0.16818879544734955,
-0.0026500856038182974,
0.16958816349506378,
0.130724638... |
https://pimcore.com/docs/platform//Pimcore/Documents#cleanup-documents-types | Cleanup Documents Types
Uninstalling bundles may not always clean up data or database tables in the process to avoid data loss.
Running the following command removes type specific tables and enum types from the documents table.
The following types are protected and cannot be cleaned up via this command: page, link, snippet, folder,hardlink ,email
You can clean up multiple types at once.
bin/console pimcore:documents:cleanup <type1> <type2> <type3>
| Cleanup Documents Types | [
-0.1670139580965042,
-0.08141332119703293,
-0.03497808426618576,
0.29007688164711,
-0.1319814771413803,
0.13995307683944702,
-0.15343338251113892,
0.3608607053756714,
-0.43090498447418213,
-0.15792177617549896,
-0.48779475688934326,
0.7623305916786194,
0.13818199932575226,
0.22891260683536... |
https://pimcore.com/docs/platform//Pimcore/Documents#document-topics | Document Topics
Creating editable templates
Navigation
Inheritance
Working with the PHP API
Predefined Document Types
| Document Topics | [
0.05775442719459534,
-0.019114870578050613,
-0.21031098067760468,
-0.08777561038732529,
0.10531708598136902,
-0.17589442431926727,
0.17422756552696228,
0.10755672305822372,
-0.3953947126865387,
-0.04196009412407875,
-0.0701703354716301,
0.47952181100845337,
-0.10119703412055969,
-0.0508327... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#working-with-assets-via-php-api | Working With Assets via PHP API
Pimcore provides an object orientated PHP API to work with Assets. | Working With Assets via PHP API | [
-0.2608553171157837,
0.050614386796951294,
-0.2906387746334076,
0.15596115589141846,
0.031662847846746445,
-0.4452461004257202,
0.30200567841529846,
0.21157877147197723,
-0.29356375336647034,
0.21372555196285248,
-0.011585228145122528,
0.36619699001312256,
-0.13025858998298645,
0.206823885... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#crud-operations | CRUD Operations
Following lines of code show simple CRUD operations for Assets.
//creating and saving new asset
$newAsset = new \Pimcore\Model\Asset();
$newAsset->setFilename("myAsset.png");
$newAsset->setData(file_get_contents("some-file.png"));
$newAsset->setParent(\Pimcore\Model\Asset::getByPath("/"));
// the optional parameter allows you to provide additional info
// currently supported:
// * versionNote: note added to the version (see version tab)
$newAsset->save(["versionNote" => "my new version"]);
//getting assets
$asset1 = \Pimcore\Model\Asset::getById(3456);
$asset2 = \Pimcore\Model\Asset::getByPath("/my-assets/sample.png");
//updating assets
$asset1->setData(file_get_contents("some-updated-file.png"));
$asset1->save();
//deleting assets
$asset2->delete();
| CRUD Operations | [
-0.14469954371452332,
-0.037082426249980927,
-0.2582956850528717,
0.22362281382083893,
-0.2214052677154541,
-0.21276330947875977,
0.1375209093093872,
0.1781911849975586,
-0.3777007758617401,
0.2860255241394043,
-0.22485822439193726,
0.2997485399246216,
0.24642153084278107,
-0.1204605922102... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#asset-listings | Asset Listings
With Asset\Listing lists of assets can be retrieved and filtered. The most important methods are setCondition,
setOffset, setLimit, setOrderKey, setOrder.
$list = new \Pimcore\Model\Asset\Listing();
$list->setCondition("...");
$list->setOrderKey("filename");
$list->setOrder("DESC");
$list->load();
Please also have a look at object listings
and document listings. | Asset Listings | [
-0.22280606627464294,
0.021370306611061096,
-0.23258036375045776,
0.2399446815252304,
0.1328175961971283,
-0.21281848847866058,
-0.0077752708457410336,
0.5922409296035767,
-0.07545743882656097,
0.2087712585926056,
-0.6395283341407776,
0.19937653839588165,
-0.07123734056949615,
0.1253971606... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#custom-settings | Custom Settings
Custom Settings/Properties can be added programmatically to every asset. This is mostly used for plugins or something
similar.
$asset = Asset::getById(2345);
$settings = $asset->getCustomSettings();
$settings["mySetting"] = "this is my value this can be everythin also an array or an object not only a string";
$asset->setCustomSettings($settings);
$asset->save();
| Custom Settings | [
-0.27278274297714233,
-0.2888087332248688,
-0.20715855062007904,
-0.00004658098259824328,
0.2241826355457306,
-0.019170347601175308,
0.20754536986351013,
0.21000273525714874,
-0.06871134042739868,
0.38398638367652893,
-0.11253233999013901,
0.14698463678359985,
-0.11939508467912674,
0.02279... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#using-(localized)-asset-metadata | Using (localized) Asset Metadata
Asset Metadata allow you to attach localized metadata to assets within Pimcore. These Medata can be accessed via API and
therefore used on all output channels. | Using (localized) Asset Metadata | [
-0.23414452373981476,
-0.11483374983072281,
-0.17771431803703308,
-0.17544624209403992,
0.34159207344055176,
-0.29715391993522644,
0.5149616003036499,
0.15600526332855225,
-0.4114376902580261,
0.21932300925254822,
-0.32389095425605774,
0.4274824857711792,
0.03925542160868645,
0.30569967627... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#examples | Examples | Examples | [
0.1105974018573761,
-0.41019901633262634,
-0.28510186076164246,
0.1324809491634369,
-0.13995729386806488,
-0.14305032789707184,
0.3125857710838318,
0.14037898182868958,
-0.0417528860270977,
0.3020334243774414,
0.41210994124412537,
0.22653697431087494,
-0.10223178565502167,
-0.0599273890256... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#getting-data | Getting Data
Metadata for an asset can be fetched using getMetadata method of Asset class. It can take the following optional parameters:
$name (string) when passed it returns the metadata with the given name, otherwise it lists all.
$language (string) with this parameter you can filter out the metadata of a specific language.
$strictMatchLanguage (boolean) if true tries to get only the metadata which exactly matches the requested language without considering the fallback.
$raw (boolean) if true, it will also return extra information like name, data, language and input type of the metadata.
To know the expected return values, you can look into the tests inside tests/Model/Asset/Metadata/NormalizerTest::testLocalizedMetaData
$asset = Asset::getById(123);
// get the title for the current language (request attribute `_locale`)
$asset->getMetadata("title");
// get the English title
$asset->getMetadata("title", "en");
// if there's no title for "en" but one without a language this will be returned (fallback mechanism).
// get all available metadata
$asset->getMetadata();
// get all available metadata for a specific language along with metadata which have no language assigned
$asset->getMetadata(null, 'en');
// get exclusively all the metadata that have a specific language
$asset->getMetadata(null, 'en', true);
// get metadata in raw format. ie: including metadata input type, language, value and name
$asset->getMetadata('title', null, true, true);
| Getting Data | [
-0.1922014057636261,
0.2382931113243103,
-0.2105252742767334,
0.38606420159339905,
0.005839348305016756,
-0.33017951250076294,
0.1187511682510376,
0.5970668792724609,
-0.27049651741981506,
0.24499164521694183,
-0.19048428535461426,
0.1802360862493515,
-0.04739566147327423,
-0.1321477442979... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#setting-data | Setting Data
// Set the English title
$asset->addMetadata("title", "input", "the new title", "en");
| Setting Data | [
-0.044843245297670364,
0.3525591194629669,
-0.2815234363079071,
-0.04461488127708435,
0.26781460642814636,
-0.07666423916816711,
0.33452507853507996,
0.2191874086856842,
-0.11652681231498718,
0.43688511848449707,
0.008167142979800701,
0.04945660009980202,
0.18309764564037323,
0.11880681663... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#removing-data | Removing Data
// Remove the English title
$asset->removeMetadata("title", "en");
// Remove the title in all languages
$asset->removeMetadata("title", "*");
| Removing Data | [
0.19627320766448975,
0.21040970087051392,
-0.28944259881973267,
0.23804309964179993,
0.09346352517604828,
0.03117367811501026,
0.32967081665992737,
0.46999379992485046,
-0.12677507102489471,
0.5133355259895325,
-0.17782418429851532,
0.05046432837843895,
0.24370764195919037,
-0.091343991458... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#predefined-system-metadata | Predefined System Metadata
There may be predefined and default fields on an Asset. That means that these fields have a special meaning and
will be used somewhere else. | Predefined System Metadata | [
0.11947246640920639,
-0.4309864342212677,
-0.13212840259075165,
0.0897136926651001,
0.4901043176651001,
-0.04765956848859787,
0.549971878528595,
-0.07672610878944397,
-0.08552779257297516,
0.1871204823255539,
0.13617877662181854,
0.16138006746768951,
0.06731156259775162,
-0.052380356937646... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_PHP_API#image-asset | Image asset
There are 3 default fields, namely title, alt and copyright. The contents of this fields will be
used as default alt and title attribute on any <img> tag generated by Pimcore for the
corresponding image.
This includes for example:
// image editable on documents
{{ pimcore_image("myImage", {"thumbnail": "xyz"}) }}
{# thumbnail html generator #}
{{ asset.getThumbnail("xyz").getHtml()|raw }}
{{ object.getMyImage().getThumbnail("xyz").getHtml()|raw }}
The copyright field will be appended to every title and alt attribute separated by |.
| Image asset | [
0.1647958606481552,
-0.08501515537500381,
-0.15630701184272766,
-0.11208099871873856,
-0.03939792886376381,
-0.16452527046203613,
0.10601158440113068,
0.009287461638450623,
0.08224444091320038,
0.04549013823270798,
-0.14931844174861908,
0.3459068834781647,
0.21466898918151855,
-0.110902369... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#image-thumbnails | Image Thumbnails
For images, Pimcore offers an advanced thumbnail-service also called 'image-pipeline'. It allows you to transform images
in unlimited steps to the expected result. You can configure them in Settings > Thumbnails.
With this service every image which is stored as an asset can be transformed. Pimcore doesn't support to modify images
which are not stored as an asset inside Pimcore.
IMPORTANT
Use Imagick PECL extension for best results, GDlib is just a fallback with limited functionality
(only PNG, JPG, GIF) and less quality!
Using ImageMagick Pimcore supports hundreds of formats including: AI, EPS, TIFF, PNG, JPG, GIF, PSD, ...
To use the thumbnailing service of Pimcore, you have to create a transformation pipeline first. To do so, open
Settings > Thumbnails and click on Add Thumbnail to create a new configuration.
The fields name, description, format and quality should be self-explanatory, the interesting part are now the transformations.
Click on + to add a new transformation, so that it look like that for example:
Important: The transformations are performed in the order from the top to the bottom. This is for example important
in the configuration above. If you first round the corners this would be performed on the original image,
and then the image will get resized, so the rounded corners are also resized which is not intended.
To retrieve a thumbnail from an asses simply call $asset->getThumbnail("thumbnail-name") on the asset object, which will return
an \Pimcore\Model\Asset\Image\Thumbnail object. The thumbnail object's __toString() method returns the path to the thumbnail file, for example:
/Car%20Images/ac%20cars/68/image-thumb__68__content/automotive-car-classic-149813.jpg
Important: The function getThumbnail() does not generate the Thumbnail itself. It just returns the path were the thumbnail file will be stored.
If you want to generate the Thumbnail directly have a look at Deferred Rendering of Thumbnails
This path can then be directly used to display the image in a <img /> or <picture> tag. For example:
$image = Asset::getById(1234);
// get path to thumbnail, e.g. `/foo/bar/362/image-thumb__362__content/foo.webp
$pathToThumbnail = $image->getThumbnail("myThumbnailName");
// preferred alternative - let Pimcore create the whole image tag
// including high-res alternatives (srcset) or media queries, if configured
$htmlCode = $image->getThumbnail("myThumbnail")->getHtml();
Same in Twig:
{% set image = pimcore_asset(1234) %}
{# get path to thumbnail, e.g. `/foo/bar/362/image-thumb__362__content/foo.webp #}
<img src="{{ image.thumbnail('myThumbnailName') }}">
{# preferred alternative - let Pimcore create the whole image tag #}
{# including high-res alternatives (srcset) or media queries, if configured #}
{{ image.thumbnail('myThumbnailName').html|raw }}
| Image Thumbnails | [
-0.2338983714580536,
-0.31338006258010864,
-0.2207246571779251,
0.18018876016139984,
-0.08950654417276382,
-0.18635322153568268,
0.39538756012916565,
0.07481525838375092,
-0.45817047357559204,
0.17615090310573578,
-0.0988699197769165,
0.3591858744621277,
0.08642946183681488,
-0.07373327016... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#explanation-of-the-transformations | Explanation of the Transformations
Transformation
Description
Configuration
Result
ORIGINAL IMAGE
This is the image which is used in the following transformations
NONE ;-)
RESIZE
The image is exactly resized to the given dimensions without respecting the ratio.
SCALE BY HEIGHT
The image is scaled respecting the ratio to the given height, the width is variable depending on the original ratio of the image (portrait, landscape).
SCALE BY WIDTH
The image is scaled respecting the ratio to the given width, the height is variable depending on the original ratio of the image (portrait, landscape).
CONTAIN
The image is scaled to either the given height or the width, depending on the ratio of the original image. That means that the image is scaled to fit into a "virtual" box with the dimensions given in the configuration.
CROP
Cuts out a box of the image starting at the given X,Y coordinates and using the width and height.
COVER
The image is resized so that it completely covers the given dimensions. Then the overlapping pieces are cropped depending on the given positioning or based on the focal point set on the source image. This is useful if you need a fixed size for a thumbnail but the source images have different ratios.
FRAME
The transformation is the same as CONTAIN the difference is, that the image gets exactly the entered dimensions by adding transparent borders left / right or top / bottom.
ROTATE
Rotates the image with the given angle. The background is transparent by default.
BACKGROUND COLOR
Background color is especially useful if you have transparent PNG as source data or if you're using the FRAME or the ROTATE transformations where you get transparencies. It allows you to give transparencies a color, and gives you the possibility to use them for examples JPEG's which doesn't support transparency.
ROUNDED CORNERS
Rounds the corners to the given width/height.
For thumbnails in action also have a look at our Live Demo. | Explanation of the Transformations | [
0.19619610905647278,
-0.4063616991043091,
-0.18418382108211517,
-0.13962680101394653,
-0.2575717270374298,
-0.2764856517314911,
0.2722027897834778,
0.04949960112571716,
-0.3331656754016876,
0.04622188210487366,
-0.15704600512981415,
0.18845146894454956,
0.1946224421262741,
0.25480851531028... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#generating-html-for-thumbnails | Generating HTML for Thumbnails
Pimcore offers the method getHTML(array $options) to get a ready to use <picture> tag for your thumbnail. When a <picture> element is not needed or desired an <img /> element can used by calling getImageTag(array $options) instead.
You can configure the generated markup with the following options:
Name
Type
Description
disableWidthHeightAttributes
bool
Width & height attributes are set automatically by Pimcore, to avoid this set this option (eg. to true => isset check)
disableAutoTitle
bool
Set to true, to disable the automatically generated title attribute (containing title and copyright from the origin image)
disableAutoAlt
bool
Set to true, to disable the automatically generated alt attribute
disableAutoCopyright
bool
Set to true, to disable the automatically appended copyright info (alt & title attribute)
disableAutoCopyright
bool
Set to true, to disable the automatically appended copyright info (alt & title attribute)
pictureAttributes
array
An key-value array of custom attributes which should be applied to the generated <picture> tag
imgAttributes
array
An key-value array of custom attributes which should be applied to the generated <img> tag
lowQualityPlaceholder
bool
Put's a small SVG/JPEG placeholder image into the src (data-uri), the real image path is placed in data-src and data-srcset.
pictureCallback
callable
A callable to modify the attributes for the generated <picture> tag. There 1 argument passed, the array of attributes.
sourceCallback
callable
A callable to modify the attributes for any of the generated <source> tag. There 1 argument passed, the array of attributes.
imgCallback
callable
A callable to modify the attributes for the generated <img> tag. There 1 argument passed, the array of attributes.
disableImgTag
bool
Set to true to not include the <img> fallback tag in the generated <picture> tag.
useDataSrc
bool
Set to true to use data-src(set) attributes instead of src(set).
| Generating HTML for Thumbnails | [
-0.1023583635687828,
-0.29241687059402466,
-0.16161708533763885,
0.011024820618331432,
0.08213326334953308,
-0.3955768048763275,
0.1157880425453186,
0.15986302495002747,
-0.14436984062194824,
0.21566753089427948,
0.01940498873591423,
0.26002413034439087,
0.11363396048545837,
0.163758590817... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#usage-examples | Usage Examples
/* Use directly on the asset object */
{{ pimcore_asset_by_path('/path/to/image.jpg').thumbnail('myThumbnail').html|raw }}
/* ... with some additional options */
{{ pimcore_asset_by_path('/path/to/image.jpg').thumbnail('myThumbnail').html({
pictureAttributes: {
data-test: "my value"
},
disableImgTag: true
})|raw }}
/* Use with the image tag in documents */
<div>
<p>
{{ pimcore_image('myImage', {'thumbnail': 'myThumbnail'}) }}
</p>
</div>
/* Use without pre-configured thumbnail */
{{ pimcore_image('myImage', {
'thumbnail': {
'width': 500,
'aspectratio': true,
'interlace': true,
'quality': 85,
'format': 'png'
}
}) }}
/* Use from an object-field */
/* where "myThumbnail" is the name of the thumbnail configuration in settings -> thumbnails */
{% if myObject.myImage %}
{{ myObject.myImage.thumbnail('myThumbnail').html|raw }}
{% endif %}
/* Use from an object-field with dynamic configuration */
<img src="{{ myObject.myImage.thumbnail({'width': 220, 'format': 'jpeg'}) }}" />
/* Use directly on the asset object using dynamic configuration */
{{ pimcore_asset_by_path('/path/to/image.jpg').thumbnail({'width': 500, 'format': 'png'}).html|raw}}
| Usage Examples | [
-0.14764094352722168,
-0.2538328468799591,
-0.17987160384655,
-0.023107875138521194,
-0.09446343034505844,
-0.3211801052093506,
0.21666961908340454,
0.13155217468738556,
-0.21491801738739014,
0.12137514352798462,
0.05589667707681656,
0.403251588344574,
0.2157294750213623,
0.044288501143455... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#advanced-examples | Advanced Examples
Pimcore returns an \Pimcore\Model\Asset\Image\Thumbnail object when calling $asset->getThumbnail("thumb-name")
which gives you even more flexibility when working with thumbnails.
$thumbnail = $asset->getThumbnail("myThumbnail");
// get the final dimensions of the thumbnail (especially useful when working with dynamic configurations)
$width = $thumbnail->getWidth();
$height = $thumbnail->getHeight();
// get the html "<picture>" tag for the thumbnail incl. custom class on the containing `<img>` tag:
echo $thumbnail->getHtml(['imgAttributes' => ["class" => "custom-class"]]);
// get the path to the thumbnail
$path = $thumbnail->getPath();
// get path and disable deferred thumbnails
$path = $thumbnail->getPath(["deferredAllowed" => false]);
// possible options: ["deferredAllowed" => true, "cacheBuster" => false, "frontend" => false]
// getting the full url to a thumbnail (including the frontend_prefix) - also works in console commands
$path = $thumbnail->getFrontendPath();
//or
$path = $this->getPath(['deferredAllowed' => false, 'frontend' => true]);
// Asset\Image\Thumbnail implements __toString(), so you can still print the path by
echo $thumbnail; // prints something like /Car%20Images/....png
// examples for callbacks, etc. for the generated <picture> tag
$thumbnail->getHtml([
'useDataSrc' => true,
'pictureAttributes' => [
'data-bar' => uniqid(),
],
'imgAttributes' => [
'data-foo' => uniqid(),
],
'imgCallback' => function ($attributes) {
// modify <img> tag attributes
$attributes['data-foo'] = 'new value';
return $attributes;
},
'sourceCallback' => function ($attributes) {
// modify <source> tag attributes
$attributes['data-custom-source-attr'] = uniqid();
return $attributes;
},
'pictureCallback' => function ($attributes) {
// modify <source> tag attributes
$attributes['data-custom-picture-attr'] = uniqid();
return $attributes;
},
'disableImgTag' => true,
'lowQualityPlaceholder' => true,
]);
// get thumbnail instance in a specific file format
$webpThumbnail = $thumbnail->getAsFormat('webp');
$webpThumbnail->getHtml();
| Advanced Examples | [
-0.13906511664390564,
-0.17303943634033203,
-0.1857297718524933,
0.17155595123767853,
-0.17686086893081665,
-0.2778226137161255,
0.19532190263271332,
0.19879655539989471,
-0.31411731243133545,
0.2684478461742401,
-0.09363208711147308,
0.31583845615386963,
-0.01442396268248558,
-0.036255784... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#more-examples | More Examples
/* adding custom html attributes to the generated <img> or <picture> tag, using a dynamic thumbnail */
{{ image.thumbnail({
'width': 180,
'height': 180,
'cover': true,
}).html({
'imgAttributes': {
'class': 'thumbnail-class',
},
'data-my-name': 'my value',
'attributes': {
'non-standard': 'HTML attributes',
'another': 'one'
}
})|raw }}
/* same with a thumbnail definition */
{{ image.thumbnail('exampleScaleWidth').html({
'pictureAttributes': {
'class': 'thumbnail-class',
},
'data-my-name': 'my value',
})|raw }}
/* disable the automatically added width & height attributes */
{{ image.thumbnail('exampleScaleWidth').html({}, ['width', 'height'])|raw }}
/* add alt text */
{{ image.thumbnail('exampleScaleWidth').html({'alt': 'top priority alt text'})|raw }}
/* OR */
{{ image.thumbnail('exampleScaleWidth').html({'defaultalt': 'default alt, if not set in image'})|raw }}
/* Output only <img> element wihout <picture> and <source> around it */
{{ image.thumbnail('exampleScaleWidth').imageTag({'alt': 'top priority alt text'}) }}
Additionally there are some special parameters to customize generated image HTML code. | More Examples | [
0.23740164935588837,
-0.47523608803749084,
-0.2380872517824173,
-0.1117103323340416,
-0.14127688109874725,
-0.1380087286233902,
0.14198072254657745,
0.1851479411125183,
-0.03920726105570793,
0.1651805192232132,
0.04096983000636101,
0.15758009254932404,
0.08527480810880661,
0.25223594903945... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#lazy-loading | Lazy Loading
By default, the images are lazy loading. This can be changed by setting the value to "eager" in the imgAttribute:
{{ image.thumbnail('example').html({
'imgAttributes': {
'loading': 'eager',
}
})|raw }}
| Lazy Loading | [
0.007362594362348318,
-0.5125539898872375,
-0.24685245752334595,
0.008137688972055912,
0.08852585405111313,
-0.020023560151457787,
0.05477757751941681,
0.31520718336105347,
0.29070615768432617,
0.20406273007392883,
-0.10850340873003006,
0.06385179609060287,
0.15034468472003937,
-0.04626026... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#using-icc-color-profiles-for-cmyk-->-rgb | Using ICC Color Profiles for CMYK -> RGB
Pimcore supports ICC color profiles to get better results when converting CMYK images (without embedded color profile)
to RGB.
Due licensing issues Pimcore doesn't include the color profiles (*.icc files) in the download package, but
you can download them for free here: Adobe ICC Profiles
or here: ICC (color.org).
After downloading the profiles put them into your project folder or anywhere else on your sever
(eg. /usr/share/color/icc). Then configure the path in the pimcore config file:
pimcore:
assets:
# Absolute path to default ICC RGB profile (if no embedded profile is given)
icc_rgb_profile: null
# Absolute path to default ICC CMYK profile (if no embedded profile is given)
icc_cmyk_profile: null
| Using ICC Color Profiles for CMYK -> RGB | [
-0.5278006792068481,
-0.35188400745391846,
-0.08662281930446625,
-0.02408130280673504,
-0.03697855770587921,
-0.06819954514503479,
0.0797710195183754,
0.24809090793132782,
-0.3618828058242798,
0.3421367108821869,
-0.04445555433630943,
0.3993724286556244,
0.06216876208782196,
0.143884509801... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#dynamic-generation-on-request | Dynamic Generation on Request
Pimcore auto-generates a thumbnail if requested but doesn't exist on the file system and is directly called via it's file path (not using any of
the getThumbnail() methods).
For example: Call https://example.com/examples/panama/6644/image-thumb__6644__contentimages/img_0037.jpeg
(/examples/panama/ is the path to the source asset, 6644 is the ID of the source asset, contentimages is the name of the thumbnail configuration, img_0037.jpeg the filename of the source asset) directly in your browser. Now pimcore checks
if the asset with the ID 6644 and the thumbnail with the key "contentimages" exists, if yes the thumbnail is
generated on-the-fly and delivered to the client. When requesting the images again the image is directly served by
the webserver (Apache, Nginx), because the file already exists (just the same way it works with the getThumbnail() methods).
The structure of the path is identically with the one generated by the getThumbnail() methods, so it doesn't
matter whether the thumbnail is generated by getThumbnail() (inside a PHP process) or on-the-fly (in a separate
process).
Of course this works only with predefined (named) thumbnail configurations and not with dynamic configurations. | Dynamic Generation on Request | [
-0.0048798443749547005,
-0.29124030470848083,
-0.15990933775901794,
0.11431139707565308,
-0.2942124307155609,
-0.4761265814304352,
0.16343531012535095,
-0.1924867033958435,
-0.44577160477638245,
0.10055988281965256,
-0.0024979314766824245,
0.15844330191612244,
0.1445976048707962,
-0.040979... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#deferred-rendering-of-thumbnails | Deferred Rendering of Thumbnails
For performance reasons, Pimcore doesn't generate the thumbnail image directly when calling getThumbnail()
on an asset, instead it generates them when they are actually needed (on request).
But sometimes it's necessary to have the actual image already generated, in this case you can pass a
2nd parameter to getThumbnail() to force the processing of the image.
$asset = Asset\Image::getById(123);
$asset->getThumbnail("myConfig", false); // set the 2nd parameter to false
The processing is also forced when calling the method getPathReference() or getPath(["deferredAllowed" => false]) on
the returning thumbnail object:
$asset->getThumbnail("myConfig")->getPathReference();
// or
$asset->getThumbnail("myConfig")->getPath(['deferredAllowed' => false]);
| Deferred Rendering of Thumbnails | [
-0.3183000385761261,
-0.14741280674934387,
-0.1775662899017334,
0.11621734499931335,
-0.09738832712173462,
-0.24488255381584167,
0.2942327558994293,
0.22241847217082977,
-0.13097944855690002,
0.392947793006897,
0.07796791940927505,
0.2845427989959717,
0.2609250545501709,
-0.378839164972305... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#high-resolution-support | High-Resolution Support
This is a special functionality to allow embedding high resolution (ppi/dpi) images.
The following is only necessary in special use-cases like Web-to-Print, in typical web-based cases, Pimcore
automatically adds the srcset attribute to <img> and <picture> tags automatically, so no manual work is necessary. | High-Resolution Support | [
-0.276309996843338,
-0.6432976126670837,
-0.18110394477844238,
0.04618144780397415,
0.08012929558753967,
0.03490114212036133,
0.04083187133073807,
0.03086838498711586,
-0.14943775534629822,
0.45139262080192566,
-0.004069166257977486,
0.34715980291366577,
0.31808289885520935,
0.237222328782... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#use-in-the-thumbnail-configuration: | Use in the Thumbnail Configuration:
The above configuration will generate a thumbnail with 500px width.
When using this configuration in combination with the image editable
using the following code
{{ pimcore_image('myImage', {'thumbnail': 'contentimages'}) }}
this will create the following output:
<img src="/Car%20Images/ac%20cars/68/image-thumb__68__contentimages/automotive-car-classic-149813@2x.png" width="250" height="190" />
It's also possible to add the high-res dynamically:
{{ pimcore_image('myImage', {thumbnail: {
width: 250,
contain: true,
highResolution: 2
}}) }}
This will create an image width = 500px | Use in the Thumbnail Configuration: | [
-0.36957210302352905,
-0.28860029578208923,
-0.20379096269607544,
-0.10181885957717896,
0.14735940098762512,
-0.36796674132347107,
-0.23824827373027802,
0.2747691571712494,
-0.3683035373687744,
0.31268972158432007,
-0.046719249337911606,
0.3396008610725403,
0.19496843218803406,
0.263189882... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#combining-"dynamic-generation-on-request"-with-high-resolution-images | Combining "Dynamic Generation on Request" with High Resolution Images
This is especially useful in the case you want to serve thumbnails depending on the ppi of the device screen or in
combination with Web2Print documents (browser preview with normal size, tripled in size for PDF ouptut).
Pimcore also utilizes this functionality internally to provide the automatically added high.res support on <img> and <picture> tags.
So again, this feature is only useful in some edge-cases. | Combining "Dynamic Generation on Request" with High Resolution Images | [
-0.2964245080947876,
-0.658996045589447,
-0.22471478581428528,
-0.07898887991905212,
-0.043029479682445526,
-0.2021603137254715,
0.18518321216106415,
0.18213523924350739,
-0.2167077213525772,
0.40709978342056274,
-0.035406433045864105,
0.2341700792312622,
0.1639244705438614,
0.421275019645... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#example | Example
{{ image.thumbnail('testThumbnailDefinitionName').path }}
this generates the followinig ouput:
/Car%20Images/ac%20cars/68/image-thumb__68__testThumbnailDefinitionName/automotive-car-classic-149813.jpg
To get an high-res version of the thumbnail, you can just add @2x before the file extension:
/Car%20Images/ac%20cars/68/image-thumb__68__content/automotive-car-classic-149813@2x.png
/Car%20Images/ac%20cars/68/image-thumb__68__content/automotive-car-classic-149813@5x.png
Using float is possible too:
/Car%20Images/ac%20cars/68/image-thumb__68__content/automotive-car-classic-149813@3.2x.png
Pimcore will then dynamically generate the thumbnails accordingly. | Example | [
-0.23309308290481567,
-0.3601383864879608,
-0.15338020026683807,
0.0723227933049202,
-0.03171006217598915,
-0.3081583082675934,
-0.024992506951093674,
0.21563872694969177,
-0.46809467673301697,
0.2853008806705475,
-0.02733023278415203,
0.4279182553291321,
-0.059670340269804,
-0.00585747696... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#media-queries-in-thumbnail-configuration | Media Queries in Thumbnail Configuration
If your're using media queries in your thumbnail configuration pimcore automatically generates a <picture> tag when calling $asset->getThumbnail("example")->getHtml().
But in some cases it is necessary to get single thumbnails for certain media queries out of the thumbnail object, which is described in the examples below.
$a = Asset::getById(71);
// list all available medias in "galleryCarousel" thumbnail configuration
p_r(array_keys(Asset\Image\Thumbnail\Config::getByName("galleryCarousel")->getMedias()));
// get the <picture> element for "galleryCarousel" => default behavior
$a->getThumbnail("galleryCarousel")->getHtml();
// get path of thumbnail for media query min-width: 940px
$a->getThumbnail("galleryCarousel")->getMedia("(min-width: 940px)");
// get <img> tag for media query min-width: 320px including @srcset 2x
$a->getThumbnail("galleryCarousel")->getMedia("(min-width: 320px)")->getHtml();
// get 2x thumbnail path for media query min-width: 320px
$a->getThumbnail("galleryCarousel")->getMedia("(min-width: 320px)", 2);
| Media Queries in Thumbnail Configuration | [
-0.31670933961868286,
-0.27957186102867126,
-0.13740813732147217,
0.1932280957698822,
-0.04514316841959953,
-0.28201523423194885,
0.21907661855220795,
0.15150143206119537,
-0.33332574367523193,
0.3685004413127899,
-0.17572103440761566,
0.23875491321086884,
0.16904041171073914,
-0.205652907... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#focal-point | Focal Point
Pimcore supports focal points on images, which are considered when images are automatically cropped.
At the moment this makes only sense if the transformation COVER is used. If a focal point is set on
the source image, it is automatically considered and the thumbnail is cropped accordingly to ensure the focus
of the image is on the focal point.
| Focal Point | [
-0.22910355031490326,
-0.5694717168807983,
-0.04605880379676819,
-0.3114543557167053,
-0.10778486728668213,
-0.3697126805782318,
0.4465670585632324,
-0.16831909120082855,
-0.547612726688385,
0.14631427824497223,
0.022843169048428535,
0.38826555013656616,
0.34889015555381775,
0.139047846198... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#clipping-support | Clipping Support
Images with an embedded clipping path (8BIM / Adobe profile meta data) are automatically clipped when generating thumbnails of them.
If you do not want to use thumbnail auto clipping, you can disable the support by adding the following config option:
assets:
image:
thumbnails:
clip_auto_support: false
| Clipping Support | [
-0.04404826834797859,
-0.36748212575912476,
-0.1476649045944214,
0.08650213479995728,
-0.08425865322351456,
-0.08770318329334259,
0.4028191566467285,
0.36717262864112854,
-0.1777539849281311,
0.48892056941986084,
0.1642094999551773,
0.21947777271270752,
0.2093033343553543,
0.05973170697689... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#note-on-using-webp-with-imagick-using-delegates | Note on using WebP with Imagick using delegates
Please ensure that your delegate definition for WebP encoding includes the -q flag, otherwise the quality
setting on thumbnails will not be considered and the default value of 75 is being used by cwebp.
Working example of a WebP encode delegate (defined in /etc/ImageMagick-6/delegates.xml):
<delegate decode="png" encode="webp" command="&quot;cwebp&quot; -quiet -q %Q &quot;%i&quot; -o &quot;%o&quot;"/>
| Note on using WebP with Imagick using delegates | [
-0.1481502503156662,
-0.20854106545448303,
-0.036785464733839035,
-0.11947256326675415,
-0.23999127745628357,
-0.06154710054397583,
0.11143497377634048,
0.38188761472702026,
0.21664480865001678,
0.25610074400901794,
-0.09269057214260101,
0.38466691970825195,
0.04020596668124199,
-0.4958030... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#downloading-asset-thumbnails | Downloading Asset Thumbnails
Besides embedding thumbnails into CMS pages and distributing them via other channels, backend users can download a thumbnail of an asset.
In order to make a thumbnail downloadable, mark "List as option in download section on image detail view" option in Image Thumbnail Advanced settings. All thumbnails with this option enabled are listed in the "Download Thumbnail" dropdown on the detail view of an Asset. To download the thumbnail of the asset choose the thumbnail from the list and hit the "Download" button. | Downloading Asset Thumbnails | [
-0.12363807111978531,
-0.23498861491680145,
-0.2766813635826111,
0.01449342630803585,
-0.07960360497236252,
0.11533860862255096,
0.17876853048801422,
0.08449249714612961,
0.036027345806360245,
0.3278292715549469,
-0.027090659365057945,
0.15188373625278473,
0.031664811074733734,
0.067122831... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#customize-auto-(web-optimized)-format | Customize Auto (Web-Optimized) Format
For most web-based applications it's recommended to use the auto configuration, which does multiple things:
automatically select the target image format (jpeg, png) based on image characteristics (such as alpha channel)
multiple additional optimized image formats (webp, avif) using progressive enhancement (in <picture tag)
runs image optimizers (such as jpegoptim and pngout) on generated images using an async queue
Even if this setting does quite a lot of stuff automatically, it's still required to set a quality in the thumbnail
configuration. This quality will be used by jpeg and png and if not configured otherwise also for webp.
If avif is supported by Imagick this won't use the quality from the thumbnail configuration, but uses a fixed value.
It is possible to customize the used alternative image formats and their qualities by using the following configuration:
pimcore:
assets:
image:
thumbnails:
auto_formats:
# the quality is used by Imagick, set to null if quality value from config should be used
# the following config is used as the default by Pimcore
# the order of the formats is used for the priority of the <source> in the <picture> tag
avif:
quality: 15
webp:
quality: null
enabled: true
| Customize Auto (Web-Optimized) Format | [
-0.2776782214641571,
-0.5055007934570312,
-0.12308860570192337,
-0.10164939612150192,
0.013682893477380276,
-0.24912536144256592,
0.06283746659755707,
0.17008857429027557,
-0.16000615060329437,
0.2931419610977173,
-0.19483038783073425,
0.18312998116016388,
0.2848520576953888,
0.10189894586... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails#config-for-disabling-all-auto-formats | Config for disabling all auto-formats
pimcore:
assets:
image:
thumbnails:
auto_formats: null
| Config for disabling all auto-formats | [
-0.18414440751075745,
-0.35610443353652954,
-0.12702232599258423,
0.02897419035434723,
0.24025973677635193,
-0.16413354873657227,
0.23528660833835602,
0.3189563751220703,
-0.4144827425479889,
0.16817307472229004,
-0.16268467903137207,
0.22314798831939697,
-0.0014808799605816603,
0.08130306... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#video-thumbnails | Video Thumbnails
Pimcore is able to convert any video to web formats automatically. It is also possible capture a
custom preview image out of the video.
IMPORTANT
To use all the following functionalities it is required to install FFMPEG on the server.
For details, please have a look at Additional Tools Installation.
| Video Thumbnails | [
-0.32597923278808594,
-0.2787694036960602,
-0.14490699768066406,
-0.20286215841770172,
0.028034647926688194,
-0.14283382892608643,
-0.024290643632411957,
0.13815344870090485,
-0.31211045384407043,
-0.03557635471224785,
-0.12034943699836731,
0.10606253147125244,
-0.18023286759853363,
0.4039... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#explanation-of-the-transformations | Explanation of the Transformations
The transfomations are adapters for the FFMPEG Filters and Options and most of the configuration is equivalent.
Transformation
Description
FFMPEG-Filter
ORIGINAL VIDEO
This is the video which is used in the following transformations
NONE ;-)
COLOR CHANEL MIXER
Adjust video input frames by re-mixing color channels
-fv colorchannelmixer
SET FRAMERATE
Convert the video to specified constant frame rate by duplicating or dropping frames as necessary
-fv fps
CUT
Set video starging and endig position
-ss and -t
MUTE
Remove the audio stream
-an
| Explanation of the Transformations | [
0.017268260940909386,
-0.17078140377998352,
-0.0916781798005104,
-0.14536580443382263,
0.0702061876654625,
-0.3328234851360321,
0.13912543654441833,
-0.008248452097177505,
-0.5651296973228455,
-0.0997835099697113,
-0.3203478157520294,
0.19358418881893158,
0.2186897099018097,
0.294407069683... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#using-video-thumbnails-in-your-code | Using Video Thumbnails in your Code | Using Video Thumbnails in your Code | [
-0.14671067893505096,
-0.24372193217277527,
-0.3015519082546234,
-0.14694823324680328,
0.08159662038087845,
-0.2827793061733246,
0.2610749304294586,
0.16850703954696655,
-0.09111195802688599,
0.14754308760166168,
0.160396009683609,
0.020342381671071053,
-0.2090151160955429,
0.2743326425552... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#examples---image-snapshots | Examples - Image Snapshots
$asset = Asset::getById(123);
if($asset instanceof Asset\Video) {
// get a preview image thumbnail of the video, resized to the configuration of "myThumbnail"
echo $asset->getImageThumbnail("myThumbnail");
// get a snapshot (image) out of the video at the time of 10 secs. (see second parameter) using a dynamic image thumbnail configuration
echo $asset->getImageThumbnail(["width" => 250], 10);
}
| Examples - Image Snapshots | [
-0.37281179428100586,
-0.42847704887390137,
-0.29065564274787903,
0.05476045981049538,
-0.20009192824363708,
-0.22345013916492462,
0.12392345070838928,
0.6079263687133789,
-0.06685367226600647,
0.2971141040325165,
0.32561445236206055,
-0.15947416424751282,
-0.17363174259662628,
-0.05957728... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#examples---video-transcoding | Examples - Video Transcoding
$asset = Asset::getById(123);
if($asset instanceof Asset\Video) {
$thumbnail = $asset->getThumbnail("myVideoThumbnail"); // returns an array
if($thumbnail["status"] == "finished") {
p_r($thumbnail["formats"]); // transcoding finished, print the paths to the different formats
/*
OUTPUTS:
Array(
"mp4" => "/Sample%20Content/Videos/123/video-thumb__123__myVideoThumbnail...mp4",
"webm" => "/Sample%20Content/Videos/123/video-thumb__123__myVideoThumbnail...webm"
)
*/
} else if ($thumbnail["status"] == "inprogress") {
echo "transcoding in progress, please wait ...";
} else {
echo "transcoding failed :(";
}
}
| Examples - Video Transcoding | [
-0.19546054303646088,
-0.34963053464889526,
-0.24671953916549683,
0.04365197569131851,
-0.207819864153862,
-0.21683955192565918,
0.23868201673030853,
0.4988793432712555,
-0.3433097004890442,
0.26997363567352295,
0.3029746115207672,
0.044523872435092926,
-0.22975385189056396,
-0.04833843186... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#adaptive-bitrate-video-streaming | Adaptive bitrate video-streaming
This feature allows you to generate a MPEG-DASH (.mpd) file for Adaptive bitrate video-streaming.
As soon as you define transformations based on the bitrates in thumbnail config, the .mpd file will be generated with bitrate streams.
The .mpd file will be referenced in generated <video> Tag.
However, you have to include a polyfill for all major browsers to support Adaptive bitrate video-streaming: https://github.com/Dash-Industry-Forum/dash.js
{{ pimcore_video('campaignVideo', {
width: auto,
height: auto,
thumbnail: 'new'
}) }}
generates frontend:
<video width="100%" height="auto" controls="controls" class="pimcore_video" preload="auto" src="blob:http://xyz/01f91372-ddd8-4d3f-ac85-e420432d9704">
<source type="video/mp4" src="/videodata/955/video-thumb__955__campaignVideo/Volkswagen-Van.mp4">
<source type="application/dash+xml" src="/videodata/955/video-thumb__955__campaignVideo/Volkswagen-Van.mpd">
</video>
| Adaptive bitrate video-streaming | [
-0.4191642105579376,
-0.5937309861183167,
-0.14421579241752625,
-0.2953602969646454,
0.3503212332725525,
-0.20634861290454865,
-0.09254609048366547,
0.2636491060256958,
-0.5664721727371216,
-0.04362556338310242,
0.16478551924228668,
0.21786846220493317,
-0.11948315799236298,
0.377029150724... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Video_Thumbnails#using-with-the-video-editable | Using with the Video Editable
Please have a look at Video Editable. | Using with the Video Editable | [
-0.22261501848697662,
-0.2540804147720337,
-0.27144432067871094,
-0.344618558883667,
0.16122354567050934,
-0.2505975067615509,
0.09122204035520554,
0.24046434462070465,
-0.26858994364738464,
0.36466845870018005,
-0.17612895369529724,
0.20850054919719696,
-0.18656042218208313,
0.22952927649... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Document_Thumbnails#asset-document-thumbnails-(pdf,-docx,-odf,-...) | Asset Document Thumbnails (PDF, DOCX, ODF, ...)
This feature allows you to create an image thumbnail of nearly any document format, like doc(x), ppt(x), pdf, xls(x),
odt, ods, odp and many others.
You can of course use existing image-thumbnail configurations to create a thumbnail of your choice.
Important
Please be aware that the processing of thumbnails for documents is done asynchronously as part of the maintenance job, under the pimcore_asset_update messenger queue
| Asset Document Thumbnails (PDF, DOCX, ODF, ...) | [
-0.3083314895629883,
-0.47563254833221436,
-0.13691511750221252,
-0.11701280623674393,
-0.25844255089759827,
-0.046766456216573715,
0.23847024142742157,
0.15250849723815918,
-0.1722315400838852,
0.19591152667999268,
-0.1197819858789444,
0.26289573311805725,
0.16749681532382965,
0.004997293... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails/Document_Thumbnails#examples | Examples
$asset = Asset::getById(123);
if($asset instanceof Asset\Document) {
// get a thumbnail of the first page, resized to the configuration of "myThumbnail"
echo $asset->getImageThumbnail("myThumbnail");
// get the thumbnail for the third (see second parameter) page using a dynamic configuration
echo $asset->getImageThumbnail(["width" => 230, "contain" => true], 2);
// get the thumbnail URL for all pages, but do not generate them immediately (see third parameter) - the thumbnails are then generated on request
$thumbnailUrls = [];
for($i=1; $i<=$asset->getPageCount(); $i++) {
$thumbnailUrls[] = $asset->getImageThumbnail("myThumbnail", $i, true);
}
}
This feature requires Ghostscript and at least Gotenberg or LibreOffice to be installed on the server.
| Examples | [
-0.17941705882549286,
-0.30805909633636475,
-0.18557603657245636,
0.23521575331687927,
-0.26321545243263245,
-0.14092624187469482,
0.03072824329137802,
0.39953941106796265,
-0.05296800658106804,
0.3725461959838867,
0.2839585542678833,
0.02977759763598442,
-0.14991821348667145,
0.0205930229... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails#working-with-thumbnails | Working With Thumbnails
Pimcore provides a sophisticated thumbnail processing engine for calculating thumbnails based on source assets. So for
different output channels Pimcore can calculate and provide optimized images in terms of dimensions, file sizes, formats
and much more.
This functionality allows true single source publishing with Pimcore. | Working With Thumbnails | [
-0.25659310817718506,
-0.2068665474653244,
-0.14159010350704193,
0.0623215027153492,
-0.23562945425510406,
-0.3140694200992584,
0.1870812475681305,
-0.010575062595307827,
-0.45716774463653564,
0.10373373329639435,
-0.21005478501319885,
0.2984332740306854,
-0.047537170350551605,
0.334258615... |
https://pimcore.com/docs/platform//Pimcore/Assets/Working_with_Thumbnails#thumbnails-are-available-for-following-file-types: | Thumbnails are available for following file types:
Image Thumbnails
Video Thumbnails
Asset Document Thumbnails
| Thumbnails are available for following file types: | [
-0.06830418109893799,
-0.4474703073501587,
-0.2929438054561615,
0.06896357238292694,
-0.0347023569047451,
0.06555759161710739,
0.2600007653236389,
0.16583672165870667,
0.012131942436099052,
0.06311610341072083,
-0.2945989668369293,
-0.09192609041929245,
-0.04529058560729027,
0.025374120101... |
https://pimcore.com/docs/platform//Pimcore/Assets/Accessing_Assets_via_WebDAV#accessing-pimcore-assets-via-webdav | Accessing Pimcore Assets via WebDAV
Pimcore provides the option to access all assets via WebDAV. To do so,
just open following URL via your browser or WebDAV client: https://YOUR-DOMAIN/asset/webdav
As user credentials use any Pimcore Backend user. Permissions for asset access are based on the users permissions. | Accessing Pimcore Assets via WebDAV | [
-0.2767099440097809,
-0.058421097695827484,
-0.20395244657993317,
0.20652878284454346,
-0.051342956721782684,
-0.13251857459545135,
0.3287191689014435,
0.1494351625442505,
-0.14282028377056122,
0.07798831164836884,
-0.32942119240760803,
0.4193781912326813,
-0.04957051947712898,
0.035270523... |
https://pimcore.com/docs/platform//Pimcore/Assets/Accessing_Assets_via_WebDAV#nginx-configuration | Nginx configuration
Please make sure to have the following changes in your project
Nginx configuration:
location ~* ^(?!/admin|/asset/webdav)(.+?)....
| Nginx configuration | [
-0.12174857407808304,
0.16376903653144836,
-0.20624154806137085,
-0.1771228015422821,
0.2097066193819046,
-0.29229703545570374,
0.3167025148868561,
0.3913094401359558,
0.07590945065021515,
0.17625606060028076,
0.054725416004657745,
-0.033892709761857986,
0.1261090636253357,
0.0328668206930... |
https://pimcore.com/docs/platform//Pimcore/Assets/Restricting_Public_Asset_Access#restricting-public-asset-access | Restricting Public Asset Access
Pimcore has following default behavior in terms of asset delivery:
All Data that is stored as Pimcore Assets can be accessed via its URL (e.g. https://mydomain.com/my-assetfolder/my-asset.jpg)
and therefore is public available without login or other access restriction!
As a consequence confidential data must not be stored as Pimcore Assets without additional protection measures.
The reason for this wanted behavior is performance. Delivering an asset directly via the web server needs significantly
less resources than starting a php process for every asset request (especially when it comes to delivering thumbnails).
If further restriction is needed, Pimcore provides two options for doing so: | Restricting Public Asset Access | [
-0.014099672436714172,
0.2981894016265869,
-0.22751547396183014,
0.15104623138904572,
-0.0055352081544697285,
-0.5297218561172485,
0.45187634229660034,
0.010518286377191544,
-0.19672605395317078,
0.20045262575149536,
-0.3339574337005615,
0.041644152253866196,
0.06077122688293457,
-0.049319... |
https://pimcore.com/docs/platform//Pimcore/Assets/Restricting_Public_Asset_Access#option-1---restricting-access-to-certain-assets-completely | Option 1 - Restricting access to certain assets completely
All confidential assets need to be stored within one (or a few) folder(s), e.g. within /protected (to set up Pimcore
backend permissions this is necessary anyway).
Apache
In the .htaccess of the project, the access to this folder has to be restricted with an additional rewrite rule. It is
important, that this rule is placed in front of the rewrite rule for asset delivery.
...
RewriteRule ^protected/.* - [F,L]
RewriteRule ^var/.*/protected(.*) - [F,L]
RewriteRule ^cache-buster\-[\d]+/protected(.*) - [F,L]
# ASSETS: check if request method is GET (because of WebDAV) and if the requested file (asset) exists on the filesystem, if both match, deliver the asset directly
...
Nginx
Add the following parts to your Nginx configuration directly after the index directive.
location ~ ^/protected/.* {
return 403;
}
location ~ ^/var/.*/protected(.*) {
return 403;
}
location ~ ^/cache-buster\-[\d]+/protected(.*) {
return 403;
}
A full configuration example can be found on this page.
Because of this rule, all assets located within /protected (also all their thumbnails) are not delivered via the web
server anymore. As a consequence also using the direct link for downloading or using the Pimcore generated img tags for
thumbnails cannot be used anymore. All delivery of these assets has to be done manually via a custom controller action. | Option 1 - Restricting access to certain assets completely | [
-0.06205248460173607,
0.3650836646556854,
-0.21225689351558685,
0.14756359159946442,
-0.19767291843891144,
-0.5040527582168579,
0.3382475674152374,
0.21218761801719666,
-0.2752208709716797,
-0.001189011032693088,
-0.334494948387146,
0.05193265900015831,
0.1048351302742958,
0.11866221576929... |
https://pimcore.com/docs/platform//Pimcore/Assets/Restricting_Public_Asset_Access#option-2---checking-permissions-before-delivery | Option 2 - Checking permissions before delivery
This option does not restrict the delivery in general, but routes the asset request to a controller action that can check
access permissions with custom business logic and then deliver the asset or not.
Again all confidential assets need to be stored within one (or a few) folders, e.g. within /protected.
Apache
In the .htaccess of the project, requests to assets of this folder need to be routed to index.php. Again, it is
important, that this rule is placed in front of the rewrite rule for asset delivery.
...
RewriteRule ^protected/(.*) %{ENV:BASE}/index.php [L]
RewriteRule ^var/.*/protected(.*) - [F,L]
RewriteRule ^cache-buster\-[\d]+/protected(.*) - [F,L]
# ASSETS: check if request method is GET (because of WebDAV) and if the requested file (asset) exists on the filesystem, if both match, deliver the asset directly
...
Nginx
Add the following parts to your Nginx configuration directly after the index directive.
rewrite ^(/protected/.*) /index.php$is_args$args last;
location ~ ^/var/.*/protected(.*) {
return 403;
}
location ~ ^/cache-buster\-[\d]+/protected(.*) {
return 403;
}
A full configuration example can be found on this page.
In the application, there has to be a route in (config/routes.yaml) and a controller action that handles the request, e.g. like the following:
# config/routes.yaml
# important this has to be the first route in the file!
asset_protect:
path: /protected/{path}
defaults: { _controller: App\Controller\MyAssetController::protectedAssetAction }
requirements:
path: '.*'
<?php
namespace App\Controller;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\Asset;
use Pimcore\Model\Asset\Service;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class MyAssetController extends FrontendController
{
public function protectedAssetAction(Request $request): Response
{
// IMPORTANT!
// Add your code here to check permission!
// the following code is responsible to deliver asset & thumbnail contents
// modify it the way you need it for your use-case
$pathInfo = $request->getPathInfo();
$asset = Asset::getByPath($pathInfo);
if ($asset){
$stream = $asset->getStream();
return new StreamedResponse(function () use ($stream) {
fpassthru($stream);
}, 200, [
'Content-Type' => 'application/pdf',
]);
} else {
return Asset\Service::getStreamedResponseByUri($pathInfo);
}
throw new AccessDeniedHttpException('Access denied.');
}
}
Of course this option has significant impact on server load and delivery performance of assets (and thumbnails). Therefore
it is not suggested to deliver all assets that way but only the confidential ones! | Option 2 - Checking permissions before delivery | [
-0.007719442248344421,
0.5366465449333191,
-0.19094893336296082,
0.11794748157262802,
-0.2321951687335968,
-0.5812081098556519,
0.3672342300415039,
0.3262498378753662,
-0.15012681484222412,
-0.030267275869846344,
-0.17792657017707825,
0.04483572766184807,
0.012637493200600147,
-0.122640706... |
https://pimcore.com/docs/platform//Pimcore/Assets#assets | Assets
Assets are files that can be managed within the Pimcore system which you can organize in folders. The most common assets
are images. Other kinds of common assets are PDF or MS Word documents which people can download from the website.
Pimcore is able to render preview images for most file types. | Assets | [
-0.14506937563419342,
-0.13709132373332977,
-0.13842390477657318,
0.2481389045715332,
0.024087512865662575,
0.13640646636486053,
-0.013024535030126572,
0.13614559173583984,
-0.40601515769958496,
-0.08462676405906677,
-0.2666299343109131,
0.13230665028095245,
0.17204619944095612,
-0.1643797... |
https://pimcore.com/docs/platform//Pimcore/Assets#following-file-types-are-supported-for-preview: | Following file types are supported for preview:
Images: All common formats such as .jpg, .png, .eps, .psd, .tif, .svg, ... (See Imagemagick website for a full list of supported formats)
Videos: All common formats such as .avi, .mp4, .mkv, .mov, ... (See FFmpeg website for a full list of supported formats)
Documents: All Microsoft Office formats such as .docx, .docm, .pptx, .xlsx and formats such as .pdf, .rtf, ... (See LibreOffice documentation for a full list of supported formats)
Please note: The asset preview tab for documents uses Google services if the Browser has no PDF
displaying capabilities and Ghostscript or LibreOffice are not availabe on the server.
Some file types, like images, can be edited directly in Pimcore and can be used to create thumbnails for different
output channels. Note that the image editor does use the miniPaint image editor under the hood.
The sub chapters of this chapter provide insight into details for
Working with Assets via PHP API
Working with Thumbnails
Accessing Assets via WebDAV
Restricting Public Asset Access
| Following file types are supported for preview: | [
-0.31018853187561035,
-0.07758788764476776,
-0.1679697036743164,
-0.0036275454331189394,
-0.015056881122291088,
-0.13712254166603088,
0.07243293523788452,
0.37610188126564026,
-0.12043243646621704,
0.041865069419145584,
-0.28055423498153687,
0.1561724841594696,
0.026463935151696205,
0.1248... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Blocks#blocks | Blocks
The block data type acts as a simple container for other data fields.
Similar to a field collection, an unlimited number of block elements can be created.
A block element can be placed into a localized field but can also contain a localized field itself.
Nesting is not possible.
The block data basically just gets serialized into a single database column.
As a consequence, this container type is not suitable, if you are planning to query the data.
| Blocks | [
-0.1455407589673996,
-0.43749433755874634,
-0.2078205943107605,
0.4492398798465729,
-0.02695041336119175,
0.036454617977142334,
0.3325957655906677,
0.23697039484977722,
0.3768494129180908,
0.12108214944601059,
-0.040449753403663635,
-0.3060535192489624,
0.03441872075200081,
0.2875346243381... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Blocks#api-usage | API Usage
Let us consider the following class definition
and object data
The value of the second input field can be retrieved as follows:
$object = DataObject\BlockClass::getById(48);
$blockItems = $object->getBlockElement1();
$firstBlockItem = $blockItems[0];
echo($firstBlockItem["input2"]->getData());
The output will be "value2".
The value can be updated in a similar way.
// ... same as above ...
$firstBlockItem["input2"]->setData(time());
$object->save();
Get Values of Localized Block Entries:
$object = DataObject\BlockClass::getById(48);
$blockItems = $object->getBlockElement1();
$firstBlockItem = $blockItems[0];
$localizedfields = $firstBlockItem["localizedfields"]->getData();
// after that use it as you would to it with `Pimcore\Model\DataObject\LocalizedField::getLocalizedValue`
Create a Block:
/**
* @var DataObject\Data\BlockElement $blockElement
*
* BlockElement( name, type, data )
*/
$object = DataObject::getById(4);
$data = [
"input1" => new BlockElement('input1', 'input', 'NewValue1'),
"input2" => new BlockElement('input2', 'input', 'NewValue2'),
"myhref" => new BlockElement('myhref', 'manyToManyRelation', [$object])
];
$blockElement = new BlockClass();
$blockElement->setBlockElement1([$data]);
Create a Block with localized fields:
$object = DataObject::getById(4);
$data = [
"input1" => new BlockElement('input1', 'input', 'NewValue1'),
"input2" => new BlockElement('input2', 'input', 'NewValue2'),
"myhref" => new BlockElement('myhref', 'manyToManyRelation', [$object]),
"localizedfields" => new BlockElement('localizedfields', 'localizedfields', new Localizedfield([
"de" => [
"localizedInput" => "Mein deutscher Text"
],
"en" => [
"localizedInput" => "My English text"
]
]))
];
$object->setMyBlockField([$data]);
| API Usage | [
-0.391912043094635,
-0.0036850988399237394,
-0.21987444162368774,
0.1544117033481598,
0.12020871043205261,
-0.43291178345680237,
0.38447028398513794,
-0.0008179779397323728,
-0.012187481857836246,
0.42847687005996704,
-0.008513795211911201,
0.10252019762992859,
0.14025306701660156,
-0.0139... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#calculated-value-datatype | Calculated Value Datatype | Calculated Value Datatype | [
-0.5381629467010498,
-0.2632872462272644,
-0.2681749165058136,
0.23302099108695984,
0.14407768845558167,
-0.28904396295547485,
0.3123093247413635,
0.08471700549125671,
0.016303585842251778,
0.08367592096328735,
-0.0958944708108902,
0.2978281080722809,
0.25706344842910767,
0.582795679569244... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#general | General
The calculated-value datatype allows you to calculate attributes based on the value of various other attributes. The
value is always calculated on the fly when calling the corresponding getter, no caching applied.
The only data stored is the one in the object's query tables for being able to query for calculated values.
Values in the query table are only updated when the data object is saved. So be careful, the values in the query
table might not be up-to-date depending on the caluclation parameters.
As display type in object editor three types are available:
Input: Single line, displayed as read-only input field.
TextArea: Multi line, displayed as read-only text area.
HTML: Multi line HTML content, displayed as display field.
| General | [
-0.35450491309165955,
-0.08472845703363419,
-0.11663902550935745,
0.5040578246116638,
-0.0919736996293068,
-0.25466853380203247,
0.2528603971004486,
0.08469370007514954,
0.034214701503515244,
0.21718770265579224,
-0.20678147673606873,
0.18461762368679047,
0.18991287052631378,
0.45765650272... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#calculation | Calculation
For defining the calculation two options are available: | Calculation | [
-0.4819946885108948,
-0.4135798215866089,
-0.30389663577079773,
-0.017436902970075607,
-0.3071766495704651,
-0.4622102975845337,
0.2108805626630783,
-0.04062279313802719,
-0.05095111206173897,
0.40266886353492737,
-0.03476429730653763,
0.15098807215690613,
0.28967729210853577,
0.1964218467... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#expression | Expression
The simplest way for defining the calculation is providing an expression. The expression language is based on the
symfony expression language component. Please
see syntax docs for details concerning
possibilities. | Expression | [
-0.2686326801776886,
-0.19293895363807678,
-0.2135634571313858,
0.0020273090340197086,
-0.3410160541534424,
-0.47036421298980713,
0.1110038012266159,
-0.00491842208430171,
-0.13902245461940765,
0.4544336497783661,
0.11530248820781708,
0.04541921243071556,
0.19533291459083557,
0.00371370580... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#available-variables | Available variables
DataObject itself as object.
Context information as data (details see Context Information for Calculation below).
| Available variables | [
0.006944245658814907,
-0.28031352162361145,
-0.253051221370697,
0.3047979772090912,
0.05915069580078125,
-0.3039669990539551,
0.10585630685091019,
-0.24436055123806,
-0.1927354484796524,
0.3615271747112274,
-0.2119581699371338,
0.2379520982503891,
0.1851082593202591,
0.21980905532836914,
... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#simple-examples | Simple examples
# print ID of data object
object.getId()
# print firstname and lastname of data object
object.getFirstname() ~ ' ' ~ object.getLastname()
# check if field is empty
object.getText() != '' ? 'yes' : 'no'
# get fieldname of current field
data.getFieldname()
| Simple examples | [
0.2929779291152954,
-0.5664922595024109,
-0.2781674265861511,
0.2230185866355896,
0.015480557456612587,
-0.039912816137075424,
0.1119987964630127,
0.37360408902168274,
-0.026122156530618668,
0.23840312659740448,
0.0885343924164772,
0.1685076802968979,
0.32363343238830566,
0.178691640496253... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#calculator-class | Calculator Class
The second option for defining the calculation is providing a php calculator class. This is especially useful for more
complex calculations and reusing the calculators.
The calculator class is a standard symfony service (or simple php class) that implements the CalculatorClassInterface. | Calculator Class | [
-0.20797036588191986,
0.0897219255566597,
-0.07728234678506851,
-0.006121343933045864,
-0.1627902239561081,
-0.19824530184268951,
0.4982805550098419,
0.03139105439186096,
-0.004685179330408573,
0.5075907111167908,
0.06824283301830292,
-0.022162677720189095,
0.2423904836177826,
-0.151519447... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#setup-in-class-definition | Setup in Class Definition
The calculator class can be defined in two ways:
Symfony service (prefered way): Provide service name prefixed with @ (e.g. @service_name), service needs to be public.
Standard PHP class: Provide fully qualified namespace name of class, Pimcore will instanciate it with new.
| Setup in Class Definition | [
-0.28646960854530334,
0.09343069046735764,
-0.007399152033030987,
0.04131517559289932,
0.12908512353897095,
-0.4110351502895355,
0.6188397407531738,
-0.203389972448349,
-0.15381678938865662,
0.4854177236557007,
-0.0022167013958096504,
0.29095980525016785,
0.2788228988647461,
0.044264379888... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#calculator-class-implementation | Calculator Class Implementation
Let's suppose we have a very simple class with 2 number fields called xValue and yValue and a calculated-value field
called sum placed inside a localizedfields container.
The PHP calculator class needs to implement the CalculatorClassInterface interface.
The compute method needs to be implemented which computes the result for the sum field.
The arguments passed into this method is the Pimcore object and the contextual information
with details about calculated-value field is affected and where it is located at
(details see Context Information for Calculation below).
namespace App;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\ClassDefinition\CalculatorClassInterface;
use Pimcore\Model\DataObject\Data\CalculatedValue;
class Calculator implements CalculatorClassInterface
{
public function compute(Concrete $object, CalculatedValue $context): string
{
if ($context->getFieldname() == "sum") {
$language = $context->getPosition();
return $object->getXValue($language) + $object->getYValue($language);
} else {
\Logger::error("unknown field");
}
}
}
As we see here, the calculator class sums up the x and y values from the corresponding language tab.
In addition to the compute method you need to implement the getCalculatedValueForEditMode method.
This method is used to display the value in object edit mode:
public function getCalculatedValueForEditMode(Concrete $object, CalculatedValue $context): string {
$language = $context->getPosition();
$result = $object->getXValue($language) . " + " . $object->getYValue($language) . " = " . $this->compute($object, $context);
return $result;
}
| Calculator Class Implementation | [
-0.42197221517562866,
0.0649825781583786,
-0.11091823130846024,
0.37469005584716797,
0.017841124907135963,
-0.42060527205467224,
0.42425963282585144,
0.0340598039329052,
-0.5145653486251831,
0.3750776946544647,
-0.020088115707039833,
0.31290075182914734,
0.41919755935668945,
-0.04532947018... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#result | Result
The visual outcome would be as follows:
| Result | [
-0.14453627169132233,
-0.6509525775909424,
-0.29214853048324585,
0.019805314019322395,
-0.12240096181631088,
-0.3510226607322693,
0.4235137403011322,
0.16025806963443756,
-0.08876330405473709,
0.31355398893356323,
0.06496883928775787,
0.4432793855667114,
0.06033271551132202,
0.181462675333... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#context-information-for-calculation | Context Information for Calculation
The content of the context information depends on the location of the calculated-value field in the
data model. | Context Information for Calculation | [
-0.2946420907974243,
-0.14585097134113312,
-0.2342182844877243,
0.38274598121643066,
-0.1721453219652176,
-0.19346883893013,
0.5032481551170349,
-0.15783433616161346,
-0.17071233689785004,
0.28335869312286377,
-0.0686163604259491,
0.18135206401348114,
0.6282089948654175,
0.2077250033617019... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#object-(top-level) | Object (top-level)
Name
Description
ownerType
"object"
fieldName
the name of the calcuated-value field (e.g. sum)
| Object (top-level) | [
-0.15315383672714233,
0.019014405086636543,
-0.1921309232711792,
0.24268877506256104,
0.04053489491343498,
-0.05810653418302536,
-0.01006587129086256,
-0.01263550203293562,
-0.011943782679736614,
0.3684578537940979,
-0.10412810742855072,
0.3704965114593506,
0.18591362237930298,
0.431660443... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#localizedfields | Localizedfields
Name
Description
position
the language ("en", "de", ...)
ownerType
"localizedfield"
ownerName
the name of the localized field ("localizedfields")
| Localizedfields | [
0.11290598660707474,
-0.19459183514118195,
-0.20737136900424957,
0.1655643731355667,
-0.007057526148855686,
-0.21152770519256592,
0.29132285714149475,
-0.03423122316598892,
0.047123368829488754,
0.33629757165908813,
0.18221168220043182,
0.11535193771123886,
0.25083568692207336,
0.130545333... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#objectbricks | Objectbricks
Name
Description
ownerType
"objectbrick"
ownerName
the name of the objectbrick field inside the object
fieldName
the name of the attribute inside the brick
index
the name of the brick
keyDefinition
the calculated-value field definition
position
the language ("en", "de", ...) if calculated field is localized
| Objectbricks | [
-0.03207894787192345,
-0.05790048465132713,
-0.1946505308151245,
0.46745064854621887,
-0.08128366619348526,
-0.014587552286684513,
0.3967708945274353,
-0.08261195570230484,
0.3877280354499817,
0.41000208258628845,
-0.22109411656856537,
0.4309270679950714,
0.06588314473628998,
0.10435661673... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#fieldcollections | Fieldcollections
Name
Description
ownerType
"fieldcollection"
ownerName
the name of the fieldcollection attribute
fieldName
the name of the attribute inside the fieldcollection
index
the index of the fieldcollection item
keyDefinition
the calculated-value field definition
| Fieldcollections | [
-0.1251143515110016,
0.18522368371486664,
-0.2215278148651123,
0.3751020133495331,
-0.1735946536064148,
-0.027879498898983,
0.09299936890602112,
0.08640645444393158,
0.0027578421868383884,
0.31755971908569336,
-0.13791769742965698,
0.5293018221855164,
0.1467883288860321,
0.1090828999876976... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#classification-store | Classification Store
Name
Description
ownerType
"classificationstore"
ownerName
the name of the fieldcollection attribute
fieldName
the name of the attribute inside the fieldcollection
position
the language
groupId
group id
keyId
key id
keyDefinition
the fielddefinition of the classificationstore attribute
| Classification Store | [
-0.016127074137330055,
0.2982936203479767,
-0.13200142979621887,
0.2625615894794464,
0.04624679684638977,
0.02017119713127613,
0.24523614346981049,
0.10143458843231201,
-0.0703015848994255,
0.11008214950561523,
-0.1407289355993271,
0.24895162880420685,
0.21474222838878632,
0.13237187266349... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Calculated_Value_Type#working-with-php-api | Working with PHP API
Getter methods on the object class are generated as usual. The code to retrieve the values would then be:
$object = DataObject::getByPath("/demoobject");
$valueDe = $object->getSum("de"); // => 38
$valueEn = $object->getSum("en"); // => 11
| Working with PHP API | [
0.007402583956718445,
0.07266731560230255,
-0.27217403054237366,
0.7345253825187683,
-0.03791442885994911,
-0.4431830644607544,
0.2200489342212677,
0.12083446979522705,
-0.14150521159172058,
0.5259550213813782,
0.03896748274564743,
0.2630058228969574,
0.1482420414686203,
0.0120689133182168... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#classification-store | Classification Store | Classification Store | [
-0.06123374402523041,
0.20762763917446136,
-0.2423088401556015,
0.30846545100212097,
0.2740902304649353,
-0.10175405442714691,
0.6472651362419128,
0.06201595813035965,
-0.011350059881806374,
-0.09691207110881805,
-0.25796329975128174,
-0.10004942864179611,
0.030524088069796562,
0.342932581... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#overview | Overview
The classification store has quite some similarities to a key/value-like datatype.
A key/value data type allows to add an arbitrary number of key/value pairs to objects with the restriction that each
key can only be added once to that object. | Overview | [
0.21061396598815918,
-0.06403455883264542,
-0.08454039692878723,
0.05669122189283371,
0.24964416027069092,
-0.008116775192320347,
0.27670902013778687,
0.024136574938893318,
-0.007145477458834648,
0.012213075533509254,
-0.16135887801647186,
0.12375208735466003,
0.04380739852786064,
0.571925... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#the-most-important-facts: | The most important facts:
There can be multiple store with completely isolated feature sets.
Inheritance is supported.
An object can have more than one classification store.
Localization is supported (optionally, can be configured in the class definition).
The classification store introduces the concept of a fallback language.
All simple data types (e.g. textarea, date, etc are supported). The store can be extended with custom data types.
Takes advantage of the built-in mechanism for the field definition + data editing (validation, etc).
Keys can be organized in groups.
A key can belong to several groups.
Individual keys currently cannot be added to the object. Instead, the corresponding groups added.
The allowed groups can be restricted via the class definition.
| The most important facts: | [
0.1447417289018631,
-0.19299830496311188,
-0.15440207719802856,
0.23936937749385834,
0.03847918286919594,
0.03815534710884094,
0.3965800702571869,
-0.05550495162606239,
0.1434316337108612,
-0.15071500837802887,
-0.29462191462516785,
0.0784568339586258,
-0.16866134107112885,
0.3090804219245... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#configuration-of-classification-stores | Configuration of Classification Stores
Before using the classification store, at least one classification store with collections, groups and keys has to be
defined. | Configuration of Classification Stores | [
-0.10023053735494614,
0.09367071837186813,
-0.15038956701755524,
0.08228674530982971,
0.23292547464370728,
0.02395377680659294,
0.5386468172073364,
0.21040041744709015,
0.08085572719573975,
0.08282557874917984,
-0.10714367777109146,
0.13395853340625763,
0.10462884604930878,
0.1257718503475... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#key-definition | Key definition
Go to classification store in Objects menu:
Add a new store if necessary
Add a key
Select type
Click on the configuration button on the right for detailed settings
Note that not all settings are respected (e.g. indexed)
| Key definition | [
-0.02705187164247036,
-0.2178148627281189,
-0.18236607313156128,
-0.19176407158374786,
0.07148164510726929,
-0.033110544085502625,
0.008225708268582821,
0.08478991687297821,
0.22920405864715576,
0.15161754190921783,
-0.22489772737026215,
0.21544712781906128,
-0.07902106642723083,
0.3345645... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#group-definition-and-key-assignment | Group definition and key assignment
Use the group editor to define and organize keys into groups
Similar to keys a sort order can be specified
Groups with lower sort order are displayed first
A key can belong to more than one group
It is not necessary for the group name to be unique
Use the grid on the right side to manage the keys belonging to the selected group
Configure sort order for the object editor, keys with lower values are listed first
Configure which keys should be mandatory in this group
| Group definition and key assignment | [
0.32093867659568787,
-0.2522408068180084,
-0.15156885981559753,
-0.045659709721803665,
0.015597461722791195,
0.04711427912116051,
0.1266876459121704,
-0.10321944952011108,
0.00433972617611289,
0.4147023558616638,
-0.02763049118220806,
0.3091464042663574,
-0.02383589744567871,
0.17372201383... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#collection-definition | Collection definition
Groups can optionally be organized into collections
A collection is simply a container which allows to add several groups at once, there is no actual logic behind it
| Collection definition | [
-0.021850435063242912,
-0.007250028662383556,
-0.2670819163322449,
-0.0058667357079684734,
-0.21196837723255157,
-0.007695426698774099,
0.11328483372926712,
-0.011819007806479931,
-0.09098799526691437,
0.172945037484169,
-0.07777856290340424,
-0.03232382982969284,
0.10687166452407837,
-0.3... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#class-definition | Class definition
Localization can be enabled, by default only the default language is available
Allowed groups can be restricted by providing a comma-separated list of group ids
There can be more than one classification store field
Configure the group sort order for the object editor, groups with lower values are listed first
Optionally you can decide whether you want to see all keys or just the non-empty ones.
Optionally you can disable add/remove of groups in object editor (in this case, groups can only added and removed via API)
Optionally you can define a limit of how many groups can be used
| Class definition | [
0.03660272806882858,
0.031999651342630386,
-0.2089335322380066,
0.16210965812206268,
0.09644996374845505,
-0.16323992609977722,
0.3044872581958771,
0.20364584028720856,
0.11848744004964828,
0.3042037785053253,
-0.24529826641082764,
0.13178400695323944,
-0.07626597583293915,
0.1724815815687... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#object-editor | Object editor
Groups can be added/removed via the add/remove buttons (see screenshot below)
Keys are displayed in the specified sort order. If the order is equal then the keys are sorted by creation date
| Object editor | [
0.3269500434398651,
-0.08502335101366043,
-0.19709059596061707,
0.16626903414726257,
-0.2630618214607239,
0.07349776476621628,
0.26316961646080017,
-0.00732424994930625,
0.01568102091550827,
0.2919488549232483,
-0.29510462284088135,
0.33941730856895447,
0.020867789164185524,
0.049120016396... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#inheritance | Inheritance
In contrast to localized fields fallback and inherited values are first resolved in a horizontal way.
If no value can be found on the same level, the parent level is scanned in the same language order.
As mentioned before, there is the concept of a default language which is just an additional pseudo language
which acts as the last resort.
Consider the following example and let’s assume that English is the fallback language for German.
We request the German value for the object at level 3.
Since the only value can be found on level 1 for the default language the tree is traversed as depicted.
| Inheritance | [
0.30046144127845764,
-0.39059963822364807,
-0.029130062088370323,
0.17488564550876617,
0.01740364357829094,
-0.3115610182285309,
0.09943876415491104,
-0.05652224272489548,
0.03573225438594818,
0.32559019327163696,
0.13910408318042755,
0.19922566413879395,
0.25438550114631653,
-0.3403977155... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#using-classification-store-via-php-api | Using Classification Store via PHP API
// setter, group id = 1, key id id = 2, language = de
// the value is of type "quantity value" where 1 is the unit ID in this example
$heightValue = new \Pimcore\Model\DataObject\Data\QuantityValue(13, 1);
$object->getClassificationStore2()->setLocalizedKeyValue(1, 2, $heightValue, "de");
// 1 = group id
$object->getClassificationStore2()->setActiveGroups([1 => true]);
// provide additional information about which collection the group belongs to
// group 1 belongs to collection with ID 2
$object->getClassificationStore2()->setGroupCollectionMapping(1, 2);
// retrieve the mapping
// this will return 2 => collection with ID 2
$object->getClassificationStore2()->getGroupCollectionMapping(1);
// getter, group id = 1, key id id = 2, language = de
$value = $object->getClassificationStore2()->getLocalizedKeyValue(1, 2, "de");
// get the list of active groups
$store = $object->getClassificationStore2();
$groups = $store->getActiveGroups();
// get all values as associative array [groupId][keyid][language] => value
$allValues = $store->getItems();
| Using Classification Store via PHP API | [
-0.4620634913444519,
0.08283980190753937,
-0.2733318507671356,
0.32806840538978577,
0.13378828763961792,
-0.3612646162509918,
0.26876842975616455,
0.23668406903743744,
-0.17391625046730042,
0.23108108341693878,
-0.2903748154640198,
0.2173265814781189,
0.21026611328125,
0.1761476695537567,
... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#retrieving-group-and-key-data | Retrieving group and key data
The ClassificationStore::getGroups() method returns an array of Group objects. In turn, the Group::getKeys() method returns an array of Key objects for that group.
/** @var \Pimcore\Model\DataObject\Classificationstore $classificationStore */
$classificationStore = $dataObject->getClassificationStoreFieldName();
foreach ($classificationStore->getGroups() as $group) {
var_dump($group->getConfiguration()->getName());
foreach ($group->getKeys() as $key) {
$keyConfiguration = $key->getConfiguration();
$value = $key->getValue();
if ($value instanceof \Pimcore\Model\DataObject\Data\QuantityValue) {
$value = (string)$value;
}
var_dump([
$keyConfiguration->getId(),
$keyConfiguration->getType(),
$keyConfiguration->getName(),
$keyConfiguration->getTitle(),
$value,
($key->getFieldDefinition() instanceof QuantityValue),
]);
}
}
The Key::getValue() method supports the language, ignoreFallbackLanguage and ignoreDefaultLanguage arguments.
/** @var \Pimcore\Model\DataObject\Classificationstore\Key $key */
$key->getValue('en_GB', true, true);
| Retrieving group and key data | [
-0.18223673105239868,
-0.019306238740682602,
-0.12704232335090637,
0.5732070803642273,
0.0111097926273942,
-0.23253853619098663,
0.14395825564861298,
0.18196313083171844,
-0.29883962869644165,
0.26380789279937744,
-0.2617804706096649,
0.31753799319267273,
0.32749542593955994,
-0.0010402915... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Classification_Store#adding-new-items-to-classification-store-through-code | Adding new items to Classification Store through code
// KeyConfig
// first of all, define the datatype which is quantity value in this example
$definition = new \Pimcore\Model\DataObject\ClassDefinition\Data\QuantityValue();
$definition->setName("height");
$definition->setTitle("Height");
$keyConfig = new \Pimcore\Model\DataObject\Classificationstore\KeyConfig();
$keyConfig->setName($name);
$keyConfig->setDescription($description);
$keyConfig->setEnabled(true);
$keyConfig->setType($definition->getFieldtype());
$keyConfig->setDefinition(json_encode($definition)); // The definition is used in object editor to render fields
$keyConfig->save();
// Group
$groupConfig = new \Pimcore\Model\DataObject\Classificationstore\GroupConfig();
$groupConfig->setName($name);
$groupConfig->setDescription($description);
$groupConfig->save();
// Collection
$collectionConfig = new \Pimcore\Model\DataObject\Classificationstore\CollectionConfig();
$collectionConfig->setName($name);
$collectionConfig->setDescription($description);
$collectionConfig->save();
// Add a group to a collection
$rel = new CollectionGroupRelation();
$rel->setGroupId($groupConfig->getId());
$rel->setColId($collectionConfig->getId());
$rel->save();
| Adding new items to Classification Store through code | [
-0.33644068241119385,
0.3114420771598816,
-0.08744636178016663,
0.15050926804542542,
0.1810564398765564,
-0.301417738199234,
0.10046423226594925,
0.15301814675331116,
-0.264937162399292,
0.11561644077301025,
-0.08142676949501038,
0.4927249848842621,
0.1724013239145279,
0.3134578764438629,
... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Consent#consent | Consent
This data type can be used to store consent of users for something like permission for sending direct mailings.
Consent itself is stored as checkbox in data object, additional meta information (like timestamp and all other things)
are stored as a note on the corresponding object. This note is created for both actions - when a consent is given and
when a consent is revoked.
| Consent | [
0.47998711466789246,
-0.17497986555099487,
-0.11234117299318314,
0.28008782863616943,
-0.19964294135570526,
0.09200387448072433,
0.02186446823179722,
-0.05125366523861885,
0.25467759370803833,
-0.1242797002196312,
0.027205711230635643,
-0.09659275412559509,
-0.18847420811653137,
0.12474340... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Consent#usage-in-pimcore-admin-backend | Usage in Pimcore Admin Backend
The consent value can be changed directly in object editor. Every time the value changes, a note with default values
is added automatically. | Usage in Pimcore Admin Backend | [
0.019581865519285202,
-0.02282828465104103,
-0.11244087666273117,
-0.3201678693294525,
-0.2243604063987732,
-0.3344990015029907,
0.14182153344154358,
-0.020466579124331474,
-0.06103719398379326,
0.34080952405929565,
-0.12388626486063004,
0.1966446191072464,
0.22231189906597137,
-0.00014317... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Consent#usage-in-php-api | Usage in PHP API
When setting consent in custom controllers or in other places, use the service Pimcore\DataObject\Consent\Service
and its methods giveConsent and revokeConsent. Please make sure that your DataObject was saved before using the Consent Service. If your DataObject doesent have an Id the note cannot be saved!
<?php
$customer = Customer::getById(345);
$consentMessage = "lorem ipsum"; //insert exact text that was displayed to the user
$metaInfo = [
'ip' => $request->getClientIp()
];
/**
* @var Pimcore\DataObject\Consent\Service $consentService
**/
$consentService->giveConsent($customer, "directMailing", $consentMessage, $metaInfo);
| Usage in PHP API | [
0.0013402390759438276,
-0.1107804998755455,
-0.0598636195063591,
-0.0332280769944191,
-0.15768106281757355,
-0.3029581606388092,
0.3155200779438019,
-0.08562157303094864,
0.16306999325752258,
0.2519148290157318,
0.08461498469114304,
-0.09135740995407104,
-0.040008340030908585,
-0.156166285... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Date_Types#date-datatypes | Date Datatypes | Date Datatypes | [
-0.20681048929691315,
-0.058332618325948715,
-0.3015501797199249,
0.2280539572238922,
0.17395396530628204,
0.048428844660520554,
0.2672557234764099,
0.09995047748088837,
0.013049999251961708,
-0.03906705975532532,
-0.045349325984716415,
-0.1391809582710266,
-0.1332908570766449,
0.297432392... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Date_Types#date,-date-&-time | Date, Date & Time
The date and date & time object fields are represented by a calender widget in the Pimcore GUI.
In the database its data is saved as unix timestamp and thereby stored in an INT data column. Programmatically
these data types are represented by a DateTime/Carbon Object. | Date, Date & Time | [
-0.07210417091846466,
-0.03315835818648338,
-0.07579248398542404,
0.41738033294677734,
-0.003927880432456732,
-0.20972947776317596,
-0.11012531816959381,
-0.10775932669639587,
-0.18331044912338257,
0.10875024646520615,
-0.07790801674127579,
0.348187118768692,
0.10961585491895676,
0.0861298... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Date_Types#time | Time
The time data field is the same drop down list of day times as in the date & time field.
It's stored as a string in a VARCHAR(5) column in the database and can be set programmatically by simply passing a
string like for example "11:00" to the field's setter. | Time | [
0.03635482117533684,
-0.04059751704335213,
-0.2391376793384552,
0.11467795819044113,
-0.013688530772924423,
0.01291799545288086,
-0.07034192979335785,
-0.0227950606495142,
-0.2714398503303528,
-0.030189258977770805,
0.08668363839387894,
0.3871629536151886,
0.13972347974777222,
0.0840849950... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Date_Types#date-range | Date Range
The dateRange object field consists of two date fields (start and end date) and can be filled
with the usual calendar widget in the Pimcore GUI or programmatically via the Pimcore API.
The two dates are stored as unix timestamps in two separate INT columns in the database. Programmatically
the date range is represented by a CarbonPeriod Object. | Date Range | [
-0.27091097831726074,
-0.20751270651817322,
-0.09640838205814362,
0.23423488438129425,
-0.2828366458415985,
-0.10366234928369522,
-0.09942068159580231,
-0.2760155200958252,
-0.4639504551887512,
0.1430918276309967,
-0.25881874561309814,
0.05086760222911835,
0.10799489170312881,
0.2015581578... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Dynamic_Select_Types#select-types-with-dynamic-options | Select Types With Dynamic Options
For the select & multiselect datatype you can specify a dynamic options provider class.
This allows you to generate a list of valid options on-the-fly instead of using a static list.
The select datatype also allows you to define the default option at runtime.
You can also add some additional static data which will be passed to the data provider.
Note that there are two ways to define an options provider.
Either simply specify the class name ...
... or the name of a Symfony service (notice the prefix).
The services.yaml would then look like this one ...
Depending on your datatype you have to implement the appropriate interface.
Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface for the Select data type options,
Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\MultiSelectOptionsProviderInterface for the Multiselect options
Implement the following methods:
getOptions should return a list of valid options in the format indicated below
getDefaultValue (Select data type only) returning the default value
hasStaticOptions should return whether your options are depending on the object context (i.e. different options for different objects) or not.
This is especially important for the object grid. For object-context depending option there will be no batch assignment mode.
Also, filtering can only be done through a text field instead of the options list.
<?php
namespace Website;
use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface;
class OptionsProvider implements SelectOptionsProviderInterface
{
public function getOptions(array $context, Data $fieldDefinition): array
{
$object = isset($context["object"]) ? $context["object"] : null;
$fieldname = "id: " . ($object ? $object->getId() : "unknown") . " - " .$context["fieldname"];
$result = array(
array("key" => $fieldname .' == A', "value" => 2),
array("key" => $fieldname .' == C', "value" => 4),
array("key" => $fieldname .' == F', "value" => 5)
);
return $result;
}
/**
* Returns the value which is defined in the 'Default value' field
*/
public function getDefaultValue(array $context, Data $fieldDefinition): ?string
{
return $fieldDefinition->getDefaultValue();
}
public function hasStaticOptions(array $context, Data $fieldDefinition): bool
{
return true;
}
}
This will generate the following options.
| Select Types With Dynamic Options | [
-0.47453176975250244,
-0.25231432914733887,
-0.0257559921592474,
0.03956909850239754,
0.008785213343799114,
-0.44636574387550354,
0.19368720054626465,
0.15864068269729614,
0.011362507939338684,
0.16427968442440033,
-0.14658696949481964,
0.4407271444797516,
-0.15339651703834534,
0.317616432... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Dynamic_Select_Types#context-information-for-the-provider-class | Context Information for the Provider Class
Note that depending the use case not all of the infos will be available.
Especially the existence of the object paramater cannot be guaranteed because the provider class will also be called when a class is saved or if you programmatically call $class->getFieldDefinitions().
Layout definition calls can be distinguished from other ones by checking if the purpose parameter is set to layout
The purpose parameter can take the following values:
Value
Description
null
unknown
layout
edit mode layout
gridconfig
grid configuration - usually no need to specify dynamic options
gridview
grid view
| Context Information for the Provider Class | [
-0.33326369524002075,
-0.04526757821440697,
-0.07087654620409012,
0.5519906282424927,
0.14304570853710175,
-0.34044528007507324,
0.09401330351829529,
-0.036035001277923584,
-0.3420048654079437,
0.30938446521759033,
0.20302550494670868,
0.08249226957559586,
0.16954652965068817,
0.0260367542... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Dynamic_Select_Types#object-(top-level) | Object (top-level)
Name
Description
object
the "object"
fieldname
the name of the select field (e.g. dynSelect)
| Object (top-level) | [
0.18559466302394867,
-0.2789372503757477,
-0.1775810718536377,
-0.15572738647460938,
0.03439868241548538,
-0.17792768776416779,
-0.046268437057733536,
0.06900667399168015,
-0.09670589119195938,
0.3590019643306732,
0.251766562461853,
0.45287707448005676,
0.12400133907794952,
0.3365395069122... |
https://pimcore.com/docs/platform//Pimcore/Objects/Object_Classes/Data_Types/Dynamic_Select_Types#localizedfields | Localizedfields
Name
Description
ownerType
"localizedfield"
ownerName
the name of the localized field ("localizedfields")
object
the "object"
fieldname
the name of the select field (e.g. dynSelect)
| Localizedfields | [
0.10404397547245026,
-0.13882462680339813,
-0.1425597369670868,
0.025677716359496117,
0.03656924515962601,
-0.2372971475124359,
0.13155187666416168,
0.030439293012022972,
-0.011754284612834454,
0.38240015506744385,
0.21827685832977295,
0.30244165658950806,
0.17047950625419617,
0.1182666793... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.