url
stringlengths
50
196
text
stringlengths
3
17.2k
heading
stringlengths
2
103
embeddings
list
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_cache
pimcore_cache This is an implementation of an in-template cache. You can use this to cache some parts directly in the template, independent of the other global definable caching functionality. This can be useful for templates which need a lot of calculation or require a huge amount of objects (like navigations, ...). pimcore_cache( name, lifetime, force) Name Type Description name string Name of cache item lifetime int Lifetime in seconds. If you define no lifetime the behavior is like the output cache, so if you make any change in Pimcore, the cache will be flushed. When specifying a lifetime this is independent from changes in the CMS. force bool Force caching, even when request is done within Pimcore admin interface
pimcore_cache
[ -0.14519299566745758, -0.3871626555919647, -0.20044450461864471, -0.135483518242836, -0.052914999425411224, 0.029743917286396027, -0.28251320123672485, 0.20616543292999268, -0.11855074018239975, 0.08691459149122238, -0.11806807667016983, 0.17691388726234436, 0.06448222696781158, -0.0142442...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#example
Example {% set cache = pimcore_cache("test_cache_key", 60) %} {% if not cache.start() %} <h1>This is some cached microtime</h1> {{ 'now'|date('U') }} {% do cache.end() %} {% endif %}
Example
[ -0.38801664113998413, -0.5652900338172913, -0.17521901428699493, -0.11910713464021683, -0.026182346045970917, -0.09566664695739746, 0.14545786380767822, 0.31197693943977356, -0.21852391958236694, 0.07690638303756714, 0.2248886525630951, 0.12189675122499466, -0.05525593459606171, 0.01178283...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_device
pimcore_device This extension makes it easy to implement "Adaptive Design" in Pimcore.
pimcore_device
[ -0.5160499215126038, -0.7018744945526123, -0.2501000165939331, -0.1347212791442871, 0.15416114032268524, -0.34464260935783386, 0.44133564829826355, 0.07935859262943268, -0.2764878571033478, 0.2889086902141571, -0.13574442267417908, 0.5096619129180908, -0.2713666260242462, 0.304256528615951...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#arguments
Arguments Name Type Description default string optional Default if no device can be detected
Arguments
[ 0.02690865285694599, -0.7659252882003784, -0.10274676233530045, -0.32660549879074097, 0.24983303248882294, -0.11418561637401581, 0.5227257609367371, 0.031390298157930374, 0.15373201668262482, 0.11117234081029892, 0.30219215154647827, 0.18388834595680237, -0.10120221972465515, -0.0810303911...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#example
Example {% set device = pimcore_device('desktop') %} {% if device.isPhone() %} This is my phone content {% elseif device.isTablet() %} This text is shown on a tablet {% elseif device.isDesktop() %} This is for default desktop Browser {% endif %} For details also see Adaptive Design.
Example
[ -0.2425488829612732, -1.007736086845398, -0.23109281063079834, -0.10691075772047043, 0.35698243975639343, -0.4188825488090515, 0.4387645125389099, 0.05202004685997963, -0.1583804488182068, 0.06167561560869217, -0.0754036009311676, 0.115816630423069, -0.10818949341773987, 0.1604765057563781...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_glossary
pimcore_glossary The pimcore_glossary filter replaces glossary terms. See Glossary for details. {% apply pimcore_glossary %} My content {% endapply %}
pimcore_glossary
[ -0.09689310938119888, -0.2859792709350586, -0.2002965211868286, -0.22244976460933685, 0.005644203629344702, -0.09586706757545471, -0.17060843110084534, 0.19540292024612427, -0.1729361116886139, 0.20842261612415314, -0.15748514235019684, 0.43781259655952454, 0.0029510476160794497, 0.2330859...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_placeholder
pimcore_placeholder See Placeholder Template Extension
pimcore_placeholder
[ -0.1877410113811493, -0.48155924677848816, -0.15418434143066406, -0.12549994885921478, 0.19606654345989227, -0.35368430614471436, 0.21731363236904144, 0.0703696757555008, -0.3099384307861328, 0.30340662598609924, 0.054923247545957565, 0.19659459590911865, 0.183890238404274, 0.0298074092715...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_head_link
pimcore_head_link See HeadLink Template Extension
pimcore_head_link
[ -0.28353995084762573, -0.5694602727890015, -0.20610499382019043, -0.04512353986501694, 0.12970955669879913, -0.12721151113510132, 0.12072969228029251, 0.09019055962562561, -0.021807001903653145, 0.14929093420505524, -0.22142882645130157, 0.5613136291503906, 0.22900134325027466, -0.01798620...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_head_meta
pimcore_head_meta See HeadMeta Template Extension
pimcore_head_meta
[ -0.32110595703125, -0.5225710868835449, -0.21614450216293335, -0.02703905664384365, 0.2603686451911926, -0.09887539595365524, 0.15142977237701416, 0.10297252237796783, -0.19471636414527893, 0.25416210293769836, -0.22434096038341522, 0.6392119526863098, 0.22818154096603394, 0.01130886748433...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_head_script
pimcore_head_script See HeadScript Template Extension
pimcore_head_script
[ -0.46960845589637756, -0.47503378987312317, -0.23289407789707184, -0.2181517630815506, 0.18232016265392303, -0.15485014021396637, 0.14964614808559418, 0.189631387591362, 0.01259241160005331, 0.27984172105789185, -0.03933648765087128, 0.477802038192749, 0.10175171494483948, 0.23246067762374...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_head_style
pimcore_head_style See HeadStyle Template Extension
pimcore_head_style
[ -0.36449292302131653, -0.5655810236930847, -0.22006790339946747, -0.1244327500462532, 0.13020238280296326, -0.13659299910068512, 0.22708086669445038, 0.15919910371303558, -0.2727110981941223, 0.30183929204940796, -0.22476528584957123, 0.5157437324523926, 0.14792728424072266, -0.03090244717...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_head_title
pimcore_head_title See HeadTitle Template Extension
pimcore_head_title
[ -0.13377322256565094, -0.35306304693222046, -0.22440850734710693, -0.057537443935871124, 0.16398485004901886, -0.008036821149289608, 0.15504203736782074, 0.13354560732841492, -0.2235884815454483, 0.4356815814971924, -0.2018430083990097, 0.4503171741962433, 0.32921501994132996, 0.0103049129...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_inc
pimcore_inc Use pimcore_inc() to include documents (eg. snippets) within views. This is especially useful for footers, headers, navigations, sidebars, teasers, ... pimcore_inc(document, params, cacheEnabled) Name Type Description document PageSnippet | int | string Document to include, can be either an ID, a path or even the Document object itself params array Is optional and should be an array with key value pairs. enabledCache bool Is true by default, set it to false to disable the cache. Hashing is done across source and parameters to ensure a consistent result.
pimcore_inc
[ -0.2543788254261017, -0.22153110802173615, -0.12258177250623703, -0.1092158704996109, -0.20284003019332886, -0.2713592052459717, -0.03324822708964348, 0.3355194628238678, -0.05187038332223892, -0.06513732671737671, -0.008990970440208912, 0.6917528510093689, -0.1773529052734375, 0.252468049...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#example
Example {#include path#} {{ pimcore_inc("/shared/boxes/buttons") }} {#include ID#} {{ pimcore_inc(256) }} {#include object#} {% set doc = pimcore_doc(477) %} {{ pimcore_inc(doc, {param: 'value'}) }} {#disable caching#} {{ pimcore_inc(123, null, false) }} When passing parameters to something included with pimcore_inc(), these parameters are not automatically passed to Twig. The parameters are passed as attributes to the included document, and should be passed to Twig via the document's controller action. Example: index.html.twig {{ pimcore_inc('/some/other/document', { 'parameterToPass': parameterToPass }) }} IndexController.php (whatever controller / method is designated for /some/other/document in the document tree) public function otherDocumentAction(Request $request): array { return ['parameterToPass' => $request->get('parameterToPass')]; } more Convenient way public function otherDocumentAction(Request $request): Response { return $this->render(":Default:someOtherDocument.html.twig", ['parameterToPass' => $request->get('parameterToPass')]); } someOtherDocument.html.twig (whatever Twig template is actually for /some/other/document in the document tree) ... {{ parameterToPass }} ...
Example
[ -0.20130077004432678, -0.11346277594566345, 0.018785281106829643, 0.33531033992767334, -0.04078264534473419, -0.30658388137817383, 0.11990822106599808, 0.25202620029449463, -0.23609638214111328, 0.11532116681337357, 0.028326882049441338, 0.8275488018989563, 0.1245977059006691, -0.071363739...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_inline_script
pimcore_inline_script See InlineScript Template Extension
pimcore_inline_script
[ -0.3865864872932434, -0.5185889601707458, -0.28995752334594727, -0.24742655456066132, 0.24847128987312317, -0.2265957146883011, 0.3528118133544922, 0.24808447062969208, -0.04558393359184265, 0.22353556752204895, 0.09291335195302963, 0.32306960225105286, -0.07614205777645111, 0.413634717464...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#navigation
Navigation pimcore_build_nav pimcore_render_nav pimcore_nav_renderer Used to interact with navigations. See Navigation for details. Simplified example: {% set navigation = pimcore_build_nav({ active: document, root: navRootDocument }) %} {{ pimcore_render_nav(navigation) }} {# you can also fetch the renderer instance and call custom render methods #} {% set renderer = pimcore_nav_renderer('menu') %} {{ renderer.render(navigation) }}
Navigation
[ -0.32284805178642273, -0.3116185963153839, -0.19681477546691895, -0.0842600017786026, 0.017122212797403336, -0.1298605501651764, 0.0248758215457201, 0.3181074559688568, -0.06491240859031677, 0.17462334036827087, -0.13641999661922455, 0.5116149187088013, 0.24040336906909943, 0.1515734940767...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#pimcore_url
pimcore_url An alternative to url() and path() which used Url. {{ pimcore_url(params, name, reset, encode, relative) }} All parameters are optional here: Name Type Description params array Route params. If object is passed in the params then link generator will be used to generate Url name string Route name reset bool Is false by default, set it to false to avoid merging parameters from request encode bool Is true by default, set it to false to disable encoding relative bool Is false by default, set it to true to generate a relative path based on the current request path
pimcore_url
[ -0.16560278832912445, -0.3111047148704529, -0.14314991235733032, -0.27736595273017883, 0.14927053451538086, -0.5730397701263428, -0.20445460081100464, 0.16270959377288818, -0.3812728524208069, 0.031218616291880608, 0.0486515611410141, 0.5975981950759888, -0.12215600162744522, 0.12215586006...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Template_Extensions#example
Example {% set object = pimcore_object(769) %} {{ pimcore_url({'object': object}) }}
Example
[ -0.12800763547420502, -0.39101192355155945, -0.1557360589504242, -0.1855722814798355, 0.23571357131004333, -0.3557920753955841, 0.157720148563385, 0.051867954432964325, -0.4815749228000641, 0.15239281952381134, 0.11824095994234085, 0.3891025483608246, -0.09191916882991791, 0.22094415128231...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Thumbnails#pimcore-thumbnails
Pimcore Thumbnails
Pimcore Thumbnails
[ -0.09739886969327927, -0.2856456935405731, -0.2998429536819458, 0.12302257120609283, -0.16814790666103363, -0.2655161917209625, 0.19191619753837585, -0.03854827582836151, -0.3149302005767822, 0.20253202319145203, -0.2096291035413742, 0.2491414099931717, -0.015172170475125313, 0.07941294461...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Thumbnails#introduction
Introduction When displaying images in templates, they should be optimized (e.g. size) for the actual use case and device. When source images are stored as Pimcore Assets (as they should be), Pimcore can do all the optimizing work for you. Just use the Thumbnail functionality and let Pimcore transform the images the way you need them. To get all the information about Thumbnails, which possibilities exist and how to configure them, please have a look at Working with Thumbnails.
Introduction
[ -0.3600601851940155, -0.35184335708618164, -0.21381376683712006, 0.0517549067735672, 0.11660166829824448, -0.2897994816303253, 0.2007378488779068, 0.13773082196712494, -0.3941190242767334, 0.1225411668419838, -0.2112809121608734, 0.2811434268951416, 0.09110704064369202, -0.0552475936710834...
https://pimcore.com/docs/platform//Pimcore/MVC/Template/Thumbnails#use-thumbnails-in-templates
Use Thumbnails in Templates {# Use directly on the asset object - myThumbnail is the name of the thumbnail configured in thumbnail configuration #} {% set asset = asset('/path/to/image.jpg') %} {{ asset.getThumbnail('myThumbnail').getHtml() | raw }} {# Use directly on the asset object using dynamic configuration #} {% set asset = asset('/path/to/image.jpg') %} {{ asset.getThumbnail({ width: 500, format: 'png' }).getHtml() | raw }} {# Use with the image editable in documents #} <div> <p> {{ pimcore_image('image', { thumbnail: 'myThumbnail', }) }} </p> </div> {# Use with the image editable in documents using dynamic configuration #} {{ pimcore_image('image', { thumbnail: { width: 500, height: 0, aspectratio: true, interlace: true, quality: 95, format: 'PNG' } }) }} {# Use from an object-field #} {% if myObject.myImage is instanceof('Asset\\Image') %} <img src="{{ myObject.myImage.getThumbnail('myThumbnail').getHref() }}" /> {% endif %} {# Use from an object-field using dynamic configuration #} {% if myObject.myImage is instanceof('Asset\\Image') %} <img src="{{ myObject.myImage.getThumbnail({width: 220, format: 'jpeg'}).getHref() }}" /> {% endif %}
Use Thumbnails in Templates
[ -0.17629209160804749, -0.3123428225517273, -0.21684230864048004, -0.029019232839345932, 0.005412430502474308, -0.24859698116779327, 0.19777901470661163, 0.3428493142127991, -0.26235780119895935, 0.06854399293661118, -0.021347304806113243, 0.3139403462409973, 0.07202538847923279, -0.0784253...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#pimcore-templates
Pimcore Templates
Pimcore Templates
[ -0.10602758824825287, -0.5359558463096619, -0.21681591868400574, 0.08903082460165024, 0.0969197079539299, -0.2804386615753174, 0.17275919020175934, -0.04121667891740799, -0.5257189273834229, 0.17960481345653534, -0.3797905445098877, 0.4435570240020752, 0.09898987412452698, 0.24557709693908...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#introduction
Introduction In general the templates are located in: templates/[controller]/[action].html.twig but Symfony-style locations also work (both controller as well as action without their suffix). Pimcore uses the Twig templating engine, you can use Twig exactly as documented in: Twig Documentation Symfony Templating Documentation Check also our Demo as starting point Just use attributes or render the view directly to use Twig: <?php namespace App\Controller; use Pimcore\Controller\FrontendController; use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\HttpFoundation\Response; class MyController extends FrontendController { /** * The attribute will resolve the defined view */ #[Template('content/default.html.twig', vars: ['param1' => 'value1'])] public function attributeAction(): void { } public function directRenderAction(): Response { return $this->render('my/custom/action.html.twig', ['param1' => 'value1']); } } Of course, you can just set a custom template for Pimcore documents in the admin interface and that template will be used for auto-rendering when the controller does not return a response.
Introduction
[ -0.07588668167591095, -0.28156739473342896, -0.03161095082759857, 0.04876640439033508, 0.09988950192928314, -0.2656393051147461, -0.02869807370007038, 0.29406973719596863, -0.25002560019493103, 0.05965204909443855, -0.23597867786884308, 0.5476759672164917, 0.0560506135225296, 0.09984793514...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#twig-reference
Twig Reference To make Pimcore's functions available in Twig templates, Pimcore implements a set of extensions. Please see our Demo as first reference how to use Pimcore with Twig. You can take a look at the implementations for further details. Note that all of Pimcore's Twig extensions are prefixed with pimcore to avoid naming collisions.
Twig Reference
[ -0.05757983773946762, -0.3533232808113098, -0.1661190241575241, -0.09211636334657669, 0.16601940989494324, -0.1332375705242157, 0.11737092584371567, -0.08781635016202927, -0.3447471261024475, 0.4145503342151642, -0.2788364589214325, 0.5931392908096313, -0.021082689985632896, -0.03289743512...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#pimcore-editables
Pimcore Editables <h1>{{ pimcore_input('headline') }}</h1> {{ pimcore_wysiwyg('content') }} {{ pimcore_select('type', { reload: true, store: [["video","video"], ["image","image"]] }) }} Please note that if you store the editable in a variable, you'll need to pipe it through the raw filter on output if it generates HTML as otherwise the HTML will be escaped by twig. {% set content = pimcore_wysiwyg('content') %} {# this will be escaped HTML #} {{ content }} {# HTML will be rendered #} {{ content|raw }}
Pimcore Editables
[ -0.18780501186847687, -0.17956501245498657, -0.16342534124851227, -0.07599017769098282, 0.41205868124961853, -0.2090914100408554, 0.002869365271180868, 0.36561131477355957, -0.29204148054122925, 0.010722368955612183, -0.4274986684322357, 0.8811742067337036, -0.1346758008003235, 0.406860917...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#functions
Functions
Functions
[ -0.04791368171572685, -0.5531676411628723, -0.4937998950481415, -0.030179865658283234, 0.1796005219221115, -0.3123769462108612, 0.15713076293468475, 0.05499470978975296, 0.08852910250425339, 0.22664079070091248, 0.017414676025509834, 0.08085231482982635, -0.20631608366966248, 0.14892238378...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#loading-objects
Loading Objects The following functions can be used to load Pimcore elements from within a template: pimcore_document pimcore_document_by_path pimcore_site pimcore_asset pimcore_asset_by_path pimcore_object pimcore_object_by_path {% set myObject = pimcore_object(123) %} {{ myObject.getTitle() }} or {% set myObject = pimcore_object_by_path("/path/to/my/object") %} {{ myObject.title }} For documents, Pimcore also provides a function to handle hardlinks through the pimcore_document_wrap_hardlink method. See PimcoreObjectExtension for details.
Loading Objects
[ -0.08384867757558823, -0.3154641389846802, -0.06869033724069595, 0.226335808634758, 0.14058846235275269, -0.07348846644163132, 0.1402072161436081, 0.04597834497690201, -0.06145074963569641, 0.19700376689434052, -0.34229254722595215, 0.6015812158584595, 0.14341986179351807, 0.08640262484550...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#subrequests
Subrequests {# include another document #} {{ pimcore_inc('/snippets/foo') }} See Template Extensions for details.
Subrequests
[ -0.0443333238363266, -0.3498208522796631, -0.16005541384220123, 0.0023147205356508493, -0.2329997718334198, -0.22374360263347626, -0.07784822583198547, 0.34133777022361755, -0.2492709904909134, 0.1694357842206955, -0.27073320746421814, 0.5149880051612854, -0.05220925807952881, 0.1553468853...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#templating-extensions
Templating Extensions The following extensions can directly be used on Twig. See Template Extensions for a detailed description of every helper: pimcore_head_link pimcore_head_meta pimcore_head_script pimcore_head_style pimcore_head_title pimcore_inline_script pimcore_placeholder pimcore_cache pimcore_url
Templating Extensions
[ -0.012532203458249569, -0.5302181839942932, -0.17087598145008087, -0.057125017046928406, 0.1529252976179123, 0.011108899489045143, 0.2209906280040741, 0.16381488740444183, -0.15892119705677032, 0.28421682119369507, -0.11886287480592728, 0.4736059010028839, 0.010642405599355698, 0.094812542...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#block-elements
Block elements As Twig does not provide a while control structure which is needed to iterate a Block editable, we introduced a function called pimcore_iterate_block to allow walking through every block element: {% for i in pimcore_iterate_block(pimcore_block('contentblock')) %} <h2>{{ pimcore_input('subline') }}</h2> {{ pimcore_wysiwyg('content') }} {% endfor %}
Block elements
[ -0.10008765012025833, -0.5729959011077881, -0.18732047080993652, -0.05827631056308746, 0.1389656513929367, 0.061866939067840576, 0.31385043263435364, 0.1746160238981247, 0.026442795991897583, 0.26944997906684875, -0.08572977781295776, 0.32685431838035583, -0.07756194472312927, 0.0405614040...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#tests
Tests
Tests
[ -0.2288813292980194, -0.4221336543560028, -0.47237199544906616, 0.012593490071594715, -0.24840481579303741, 0.13968591392040253, 0.39429399371147156, 0.2906911373138428, 0.12639671564102173, 0.24035607278347015, 0.3234146237373352, -0.2124418169260025, -0.2266676276922226, 0.03702641651034...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#instanceof
instanceof Can be used to test if an object is an instance of a given class. {% if image is instanceof('\\Pimcore\\Model\\Asset\\Image') %} {# ... #} {% endif %}
instanceof
[ -0.07593436539173126, -0.5031116604804993, -0.11918924748897552, 0.07843673974275589, 0.036421652883291245, -0.10337994247674942, 0.1669779270887375, 0.40445977449417114, 0.06532533466815948, 0.17514680325984955, 0.1738317310810089, 0.20979495346546173, -0.26662787795066833, -0.03118948452...
https://pimcore.com/docs/platform//Pimcore/MVC/Template#pimcore-specialities
Pimcore Specialities Pimcore provides a few special functionalities to make templates even more powerful. These are explained in following sub chapters: Template inheritance and Layouts - Use layouts and template inheritance to define everything that repeats on a page. Template Extensions - Use twig extensions for things like includes, translations, cache, glossary, etc. Thumbnails - Learn how to include images into templates with using Thumbnails.
Pimcore Specialities
[ -0.043849699199199677, -0.491059273481369, -0.1516774445772171, -0.009622680023312569, -0.013669382780790329, 0.05500315502285957, -0.097955122590065, -0.1061844676733017, -0.4301920533180237, 0.20381911098957062, -0.23769128322601318, 0.4817132353782654, 0.04684989154338837, 0.01773375459...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#urls-based-on-documents-and-pretty-urls
URLs Based on Documents and Pretty URLs
URLs Based on Documents and Pretty URLs
[ 0.18345335125923157, 0.17637909948825836, -0.24577267467975616, 0.03957675024867058, -0.0162398312240839, -0.3365090787410736, -0.014369278214871883, 0.3203907012939453, -0.5458467602729797, -0.13867045938968658, 0.045337576419115067, 0.07184916734695435, -0.12873917818069458, -0.177865579...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#introduction
Introduction One essential routing option in Pimcore are the Pimcore Document paths. Along with Pretty URLs they define the address of a Document in the Browser. The Document path and pretty URLs come third in the route processing priority.
Introduction
[ -0.09261612594127655, -0.30129101872444153, -0.06508289277553558, -0.2540523111820221, -0.14053046703338623, -0.24838559329509735, -0.2327185571193695, -0.15974929928779602, -0.5997321605682373, 0.009584084153175354, 0.024090344086289406, 0.5831179618835449, 0.14056022465229034, 0.06350260...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#document-path
Document Path Every document has a path (in the document tree) that directly represents the address in the browser (e.g. https://demo.pimcore.org/en/basic-examples). If there is a document path matching the requested path info, the route then uses the controller, action and view defined in the document's settings, passing them to the dispatcher along with the document itself. See Documents documentation for more details for setting of Documents.
Document Path
[ 0.08501964062452316, -0.32151156663894653, -0.01623673178255558, 0.04779503494501114, -0.11654526740312576, -0.5075669288635254, -0.017518464475870132, -0.04603427276015282, -0.4020548462867737, 0.15552252531051636, 0.09005867689847946, 0.6788836121559143, 0.2622184157371521, 0.11533306539...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#pretty-url-(custom-slugs--clean-url)
Pretty URL (Custom Slugs / Clean URL) The Pretty URL setting overrides a document's full path only for the purpose of routing. This is useful for when you would like to create shorter paths or friendly URLs for sharing. A Pretty URL does not redirect to the original URL. Pretty URLs can be defined in the Documents settings as shown in the screen below:
Pretty URL (Custom Slugs / Clean URL)
[ 0.16496406495571136, -0.3566066026687622, -0.10017465054988861, -0.23886871337890625, -0.10736382007598877, -0.11787284910678864, -0.13435551524162292, 0.16236376762390137, -0.6497290730476379, -0.06329807639122009, -0.049168411642313004, 0.14275303483009338, 0.03831470385193825, -0.057897...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#creating-url's-to-documents
Creating URL's to Documents The default route is also responsible to assemble the URL's for documents.
Creating URL's to Documents
[ 0.22783954441547394, -0.13966244459152222, -0.06102776899933815, -0.13181830942630768, -0.21842996776103973, -0.16084133088588715, 0.12230168282985687, 0.02200082689523697, -0.24089814722537994, 0.05845969170331955, 0.15975171327590942, 0.24959570169448853, 0.14172638952732086, 0.005173732...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#example
Example
Example
[ -0.039029549807310104, -0.4887920916080475, -0.3070780634880066, 0.04008098319172859, -0.14495046436786652, -0.15570281445980072, 0.2727290093898773, 0.16836415231227875, -0.006077707279473543, 0.44112470746040344, 0.5344760417938232, 0.21058650314807892, -0.14281579852104187, 0.0040315156...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#simple-link-to-different-document
Simple Link to Different Document <a href="{{ pimcore_document(2) }}">Test-Link</a> /* OR */ {% set document = pimcore_document(2) %} <a href="{{ document.fullpath }}">Test-Link</a> Links to /about
Simple Link to Different Document
[ -0.16517502069473267, -0.4896508753299713, -0.21604996919631958, -0.135658398270607, 0.021553492173552513, -0.1393195539712906, 0.10359476506710052, 0.15010783076286316, -0.27042385935783386, 0.04965752735733986, 0.03529500588774681, 0.19666588306427002, 0.16661643981933594, 0.200488045811...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Documents_and_Pretty_URLs#link-to-same-document-(the-request-came-from)-adding-parameters
Link to Same Document (The Request Came From) Adding Parameters <a href="{{ pimcore_url({'key': 'value'}) }}">Test-Link</a> Links to /about?key=value
Link to Same Document (The Request Came From) Adding Parameters
[ 0.02321077138185501, -0.22027559578418732, -0.21512733399868011, -0.18449388444423676, 0.025677233934402466, -0.43319085240364075, -0.18207146227359772, 0.2983528673648834, -0.40621262788772583, 0.08671457320451736, -0.04581773281097412, 0.6261170506477356, 0.21385778486728668, 0.180636018...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#urls-based-on-custom-(static)-routes
URLs Based on Custom (Static) Routes :::caution To use this feature, please enable the PimcoreStaticRoutesBundle in your bundle.php file and install it accordingly with the following command: bin/console pimcore:bundle:install PimcoreStaticRoutesBundle :::
URLs Based on Custom (Static) Routes
[ -0.20419089496135712, -0.25420910120010376, -0.14550752937793732, 0.0011483138659968972, 0.10109677910804749, -0.5251506567001343, 0.18288792669773102, -0.012390988878905773, -0.5057613253593445, -0.056687772274017334, -0.0642818734049797, 0.5412212610244751, -0.0175611674785614, 0.0528021...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#introduction
Introduction Static routes are necessary for functionalities where you don't have an underlying document or where you have the need of dynamic URLs. For example you have a news list, which is generated out of a Pimcore object list and you want to give the news a detail page. Or you want create product lists with detail pages, or cart pages, a checkout process, ... All things where Documents are not practical. Here Custom Routes come into action and allow the definition of URL patterns that are delegated to specific controllers with specific views. Custom Routes come fourth in the route processing priority. Custom routes are an alternative to Symfony's routing functionalities and give you a bit more flexibility, but you can still use Symfony's routing capabilities (eg. #[Route] attribute, routing.yaml, ...) in parallel to Pimcore Custom Routes.
Introduction
[ 0.19695904850959778, -0.26285794377326965, -0.017547743394970894, -0.1411527842283249, -0.17899790406227112, -0.3758293390274048, 0.2426285445690155, 0.05776568502187729, -0.17384012043476105, -0.04885468631982803, -0.019230453297495842, 0.2536875605583191, 0.0025170680601149797, -0.275316...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#configuring-custom-routes
Configuring Custom Routes Custom Routes are configured in the Pimcore backend interface as follows. Following options are relevant: Name - name of the Custom Route for identifying it Pattern - URL pattern configured with a regex Reverse - reverse pattern that is used to build URLs for this route, see also Building URLs. Controller - Module/controller/action configuration for which the request is delegated to. You can use a Service as Controller Name as well. Variables - comma-seperated list of names for the placeholders in the pattern regex. At least all variables used in the reverse pattern must be listed here. Defaults - defaults for variables separated by | - e.g. key=value|key2=value2 Site - Site for which this route should be applied to. Priority - priority in resolving the URL pattern. Methods - define which HTTP Methods are valid. You can define multiple by using a comma as delimiter. If empty, all are allowed. (one of HEAD, GET, POST, PUT, PATCH, DELETE, PURGE, OPTIONS, TRACE or CONNECT) Routes are saved in PHP configuration files on the file system (var/config/staticroutes.php), so it's also possible to edit them directly in your favorite IDE and keep track of the changes in your VCS (eg. Git).
Configuring Custom Routes
[ 0.09749250113964081, -0.18214033544063568, -0.09259240329265594, -0.14840298891067505, -0.20427455008029938, -0.49821650981903076, -0.03937429562211037, -0.25236430764198303, -0.39753857254981995, -0.004903577268123627, -0.1865617334842682, 0.41762205958366394, 0.24507459998130798, 0.17831...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#accessing-variables-in-controller
Accessing Variables in Controller This is how you can access (form a controller action) the values of the variables (placeholders) you specified in the custom route: <?php namespace App\Controller; use Pimcore\Controller\FrontendController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class NewsController extends FrontendController { public function detailAction(Request $request): Response { $id = $request->get('news'); $text = $request->get('text'); // ... return $this->render('news/detail.html.twig'); } } The default variables can be accessed the same way.
Accessing Variables in Controller
[ -0.0875280499458313, -0.14350394904613495, -0.09557458758354187, 0.17781643569469452, 0.13121630251407623, -0.37309449911117554, 0.05407867580652237, -0.04124829173088074, -0.16706056892871857, 0.2731480896472931, -0.18494804203510284, 0.4127831757068634, 0.17173561453819275, 0.08098006993...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#using-param-resolver-to-convert-request-id-to-data-object
Using Param Resolver to convert request ID to Data Object Pimcore has a built-in param resolver for converting data object IDs in the request parameters to actual objects. To use the param resolver, simply type hint the argument (Symfony routing example): use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; .... #[Template('/news/test')] #[Route('/news/{news}')] public function detailAction(DataObject\News $news): array { return [ 'news' => $news ]; } Param resolvers work with Pimcore Custom Routes as well as with Symfony Routes. By taking advantage of #[DataObjectParam] attribute, we can pass further options on to the object, e.g. working with unpublished objects. public function detailAction( #[DataObjectParam(unpublished: true)] DataObject\News $news ): Response { ... }
Using Param Resolver to convert request ID to Data Object
[ 0.060877010226249695, 0.12584415078163147, -0.011912040412425995, 0.022970685735344887, 0.048747994005680084, -0.559265673160553, 0.18838085234165192, 0.09133381396532059, -0.4082890450954437, 0.05137105658650398, -0.30428481101989746, 0.5374215841293335, 0.13291053473949432, -0.0248096808...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#building-urls-based-on-custom-routes
Building URLs based on Custom Routes URLs are generated using the default Twig Extensions provided by Symfony path() and url(). Additionally to the standard extensions for generating URLs, Pimcore offers a special templating extension (pimcore_url()) to generate URLs like you did with Pimcore 4. You can define a placeholder in the reverse pattern with %NAME and it is also possible to define an optional part, to do so just embrace the part with curly brackets { } (see example below). Name Pattern Reverse Controller Variables Defaults Site IDs Priority Methods news category /\/news-category\/([^]+)([0-9]+)(category)?([0-9]+)?/ /news-category/%text_%id{category%categoryId} App\Controller\NewsController::listingAction text,id,text2,categoryId 1 Due to optional parameters, the above example matches for the following URL's: /news-category/testcategory_12_category_2 /news-category/testcategory_12
Building URLs based on Custom Routes
[ 0.2557161748409271, -0.17551036179065704, 0.041084080934524536, -0.039339423179626465, 0.001893039676360786, -0.4193975329399109, 0.04407723620533943, 0.04933556541800499, -0.29790323972702026, -0.07018616795539856, -0.2261108011007309, 0.5494862198829651, 0.07981866598129272, -0.033308990...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#generating-url-with-optional-parameters
Generating URL with Optional Parameters Source url: /some-other-url path('news category', { text: 'Test', id: 67, categoryId: 33, getExample: 'some value' }) Since there is no default parameter available out of the route pattern, you have to set every not optional parameter. In addition there is one parameter which is not in the reverse route. That will be added as a normal GET parameter in the URL. Output will be: /news-category/test_67_category_33?getExample=some+value
Generating URL with Optional Parameters
[ 0.24998578429222107, -0.24999767541885376, -0.048172347247600555, -0.21993368864059448, 0.14415964484214783, -0.45396456122398376, -0.17136123776435852, 0.1915677785873413, -0.3783245086669922, 0.06336519867181778, 0.17422303557395935, 0.6401602625846863, -0.0267884973436594, 0.07612948864...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#adding-default-values-to-the-route
Adding Default Values to the Route You can use the Defaults column to add default values which will be used if you don't specify parameters in the url helper. ... Defaults ... ... text=random text ... path('news category', { categoryId: 776, }) Output will be: /news-category/random+text_5_category_776
Adding Default Values to the Route
[ 0.11226458847522736, -0.12168373912572861, -0.09785191714763641, -0.18338677287101746, 0.32472115755081177, -0.3489941954612732, 0.05006127431988716, 0.026025835424661636, -0.2685219645500183, 0.14461661875247955, 0.33817604184150696, 0.5510552525520325, -0.15931713581085205, 0.13386856019...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#setting-locale-from-a-route
Setting locale from a route Symfony supports a special _locale parameter which is automatically used as current locale if set via route parameters (see https://symfony.com/doc/current/translation/locale.html#the-locale-and-the-url). As an example a simple route matching /{_locale}/test: Name Pattern Reverse Controller Variables Defaults Site Priority Methods myroute /^\/([a-z]{2}\/test/ /%_locale/test App\Controller\ContentController::testAction _locale 1 Whatever is matched in _locale will be automatically used as site-wide locale for the request.
Setting locale from a route
[ -0.025872332975268364, -0.060684867203235626, -0.03472663834691048, -0.2137848436832428, -0.01942545734345913, -0.4068251848220825, 0.22996699810028076, 0.09762824326753616, -0.021847913041710854, 0.30938079953193665, 0.05935874953866005, 0.10574027895927429, 0.15258806943893433, -0.055423...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#mappping-other-parameters-to-_locale
Mappping other parameters to _locale When migrating an existing site to Pimcore 5/6 you may already have static routes which rely on another parameter (e.g. language) to define the locale for the request. To avoid having to migrate those static routes and locations where the routes are generated, you can use the following configuration setting to map parameters to _locale. This mapping is only used if no _locale is set for the matched route. # will map the static route parameter "language" to "_locale" pimcore: routing: static: locale_params: - language
Mappping other parameters to _locale
[ -0.2056778371334076, -0.05492206662893295, -0.06161189451813698, -0.07642778754234314, 0.33941319584846497, -0.4780822694301605, 0.09568165242671967, 0.21040023863315582, -0.34043970704078674, 0.23856909573078156, -0.290119469165802, 0.32926902174949646, 0.244172140955925, -0.0958899334073...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#setting-priorities
Setting priorities There might be cases where you want to use a same pattern at the beginning, but in same time you require a completely different controller, action or additional parameters. In the example below you can see when exactly you need to set the priorities, if you leave those empty, depending on your environment, you may experience an uncommon behavior where one of your pattern will be completely ignored. In example below you can see how both routes are regulated by priorities. ... Pattern Reverse Controller Variables ... Priority Methods ... //blog/(.+)/ /blog/%month App\Controller\BlogController::listAction month ... 1 ... //blog/(.+)/(.+)/ /blog/%month/%id App\Controller\BlogController::detailAction month,id ... 2
Setting priorities
[ 0.16600942611694336, -0.205935537815094, -0.08820182830095291, 0.01198369637131691, -0.030875401571393013, -0.5654895305633545, 0.08922538161277771, -0.01697184145450592, -0.3061739206314087, -0.002341633662581444, 0.1611568033695221, 0.3490963578224182, 0.11941084265708923, 0.339049547910...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#site-support
Site Support It's possible to generate URL's pointing to a different Site inside Pimcore. To do so, set the option Site.
Site Support
[ -0.11913680285215378, -0.13852658867835999, -0.12730883061885834, -0.05051705986261368, 0.16970796883106232, -0.31994882225990295, 0.27822357416152954, -0.07155191898345947, -0.2467820942401886, 0.21316039562225342, -0.3252668082714081, 0.44571882486343384, 0.1428401619195938, 0.1985308229...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#example:-linking-to-the-site-with-the-id-3
Example: Linking to the Site with the ID 3 {# using the Site object #} {{ path('news', { id: 4, text: "some-text", site: pimcore_site(3) }) }} {# using the ID #} {{ path('news', { id: 4, text: "some-text", site: 3 }) }} {# using one of the hostname assiged to the site #} {{ path('news', { id: 4, text: "some-text", site: "subsite.example.com" }) }}
Example: Linking to the Site with the ID 3
[ -0.12711970508098602, -0.589556872844696, -0.14997585117816925, 0.30732986330986023, 0.048818375915288925, -0.2543550133705139, 0.10525902360677719, -0.11949068307876587, -0.006844859570264816, 0.06795034557580948, -0.15069860219955444, 0.4408515393733978, 0.04694540798664093, 0.0081023983...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#example:-linking-back-to-the-main-site
Example: Linking Back to the Main-Site {{ path('news', { id: 4, text: "some-text", site: 0 }) }}
Example: Linking Back to the Main-Site
[ -0.07081358879804611, -0.4098685681819916, -0.21885275840759277, -0.16820302605628967, 0.06870514899492264, -0.2215202897787094, 0.03103787824511528, 0.07990997284650803, 0.1092139258980751, 0.017978155985474586, 0.1526709645986557, 0.24475862085819244, 0.1083967536687851, 0.12422076612710...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#using-controller-as-service-in-custom-routes
Using Controller as Service in Custom Routes Pimcore supports Controller as Services in Custom Routes. To add them, set the Controller Setting to your Service name. Service Definition: services: app.controller.default: class: App\Controller\DefaultController calls: - [setContainer, ['@service_container']] It works similar to the reverse route, you can place your placeholders directly into the controller. The following configuration should explain the way how it works: ... Pattern Reverse Controller Variables ... Priority Methods ... //default/ /default @app.controller.default month ... 10
Using Controller as Service in Custom Routes
[ 0.011428838595747948, -0.10426998883485794, -0.07542882859706879, -0.3169374167919159, 0.009527149610221386, -0.41931748390197754, 0.13907743990421295, 0.017706384882330894, -0.14712342619895935, 0.14199186861515045, -0.07868301123380661, 0.7417414784431458, 0.1663287729024887, 0.225151836...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Custom_Routes#responding-404-status-code
Responding 404 Status Code Sometimes you want to trigger a correct 404 error within your controller/action (addressed by a custom route), for example when a requested object (in the route) doesn't exist anymore. Example: use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException; // ... public function testAction(Request $request): Response { $object = DataObject::getById((int) $request->get('id')); if( !$object || ( !$object->isPublished() && !$this->editmode) ) { throw new NotFoundHttpException('Not found'); } // ... }
Responding 404 Status Code
[ -0.0062127565033733845, -0.037417568266391754, -0.1417035609483719, -0.0846237912774086, -0.22066693007946014, -0.34081482887268066, 0.13530725240707397, 0.3152838945388794, -0.04923747107386589, 0.2584463953971863, 0.12431253492832184, 0.030541833490133286, -0.06622578948736191, -0.211686...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#urls-based-on-redirects
URLs Based on Redirects :::caution To use this feature, please enable the PimcoreSeoBundle in your bundle.php file and install it accordingly with the following command: bin/console pimcore:bundle:install PimcoreSeoBundle :::
URLs Based on Redirects
[ -0.14798659086227417, -0.20766709744930267, -0.1869228184223175, -0.03266284987330437, 0.04094717279076576, -0.4500059187412262, 0.19143500924110413, 0.019399862736463547, -0.5314930081367493, -0.04314912110567093, -0.12276769429445267, 0.4525422155857086, 0.03931575268507004, 0.1063626930...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#introduction
Introduction Redirects are a useful feature of Pimcore for directing the user to the correct pages - may it be for marketing URLs, for redirects after a website relaunch or redirects for moved Documents. Depending on their priority, Redirects come second (priority 99) or fifth (all other priorities) in the route processing priority.
Introduction
[ 0.017069842666387558, -0.41379785537719727, -0.08013641834259033, -0.3040195405483246, -0.11499108374118805, -0.2226586490869522, -0.22734424471855164, -0.1129806861281395, -0.4654982089996338, -0.1720593422651291, -0.08418134599924088, 0.12962029874324799, 0.240990549325943, 0.09003774076...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#setting-up-redirects
Setting up Redirects Redirects are configured in the Redirects editor, accessible via the Tools menu.
Setting up Redirects
[ 0.09962356090545654, -0.22959348559379578, -0.20346759259700775, -0.33112242817878723, 0.015822352841496468, -0.1776759922504425, 0.30087247490882874, -0.053565043956041336, -0.11285677552223206, 0.1506868600845337, -0.15869984030723572, -0.08969678729772568, 0.2625409960746765, 0.04418350...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#regular-expression-and-back-reference-syntax
Regular Expression and Back-Reference Syntax You can use regular expressions to define the sources, the placeholders in the regex can be accessed in the target URL using the PCRE back-reference syntax. Notice: Only simple $1-n references are possible, no special back-reference syntax.
Regular Expression and Back-Reference Syntax
[ 0.12613485753536224, -0.03662639483809471, -0.13639937341213226, -0.20843985676765442, 0.02069125510752201, -0.49115046858787537, -0.006375846918672323, -0.1312257945537567, -0.44862350821495056, 0.0060212211683392525, -0.005761340260505676, -0.03110666759312153, 0.08538520336151123, 0.143...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#priority
Priority Each redirect has a priority. 99 (override all): Redirects with priority 99 come second in route processing and therefore overwrite document paths and custom routes. 1 (lowest) - 10 (highest): Redirects with priority 1 to 10 come fifth in route processing and are processed after document paths and custom routes.
Priority
[ 0.1248713880777359, -0.3926336169242859, -0.12427154183387756, -0.13991932570934296, -0.2133120447397232, -0.3921073377132416, -0.09483618289232254, -0.05312760919332504, -0.20059990882873535, -0.2250945121049881, 0.05121419578790665, 0.3045244514942169, 0.2755739986896515, 0.1664642393589...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#creating-redirects-when-moving-or-renaming-documents
Creating Redirects When Moving or Renaming Documents Pimcore provides the ability to automatically create Redirects when renaming and moving Documents (in terms of SEO and user experience). A User will be prompted with the auto redirect option on performing these actions on documents.
Creating Redirects When Moving or Renaming Documents
[ 0.07861704379320145, -0.1542324721813202, -0.07863153517246246, -0.27777642011642456, -0.15858782827854156, -0.31146326661109924, 0.023310432210564613, -0.16447699069976807, -0.44981473684310913, 0.03787733614444733, -0.02204643376171589, 0.266438752412796, 0.06502256542444229, -0.05294103...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Redirects#creating-custom-redirect-status-codes
Creating custom redirect status codes The redirect status codes list can be extended by adding custom codes in config.yaml: pimcore_seo: redirects: status_codes: 308: Permanent Redirect The new status codes can be seen in admin.
Creating custom redirect status codes
[ 0.0368645153939724, -0.3428579568862915, -0.11130919307470322, -0.34527966380119324, 0.0793662965297699, -0.3050961494445801, 0.13739655911922455, -0.08645167201757431, -0.32961663603782654, 0.013645884580910206, -0.2124757617712021, 0.18558205664157867, 0.08194936811923981, 0.332987546920...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#working-with-sites
Working With Sites
Working With Sites
[ -0.012283924967050552, -0.40469861030578613, -0.2995273470878601, 0.13709168136119843, 0.24991878867149353, -0.11096672713756561, 0.3724789023399353, -0.025513404980301857, 0.0549505241215229, 0.09900565445423126, -0.1305137574672699, -0.04255548119544983, 0.10115885734558105, 0.2739360928...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#introduction
Introduction With Sites, it is possible to create multi domain web applications within Pimcore. Starting point is always a certain node in the Documents tree. From this starting point on, the whole sub tree can appear as an own Site and is reachable with a certain domain.
Introduction
[ -0.12829603254795074, -0.49002477526664734, -0.17114964127540588, 0.2708951532840729, 0.09321122616529465, -0.30006712675094604, 0.08358514308929443, -0.47136643528938293, -0.32511013746261597, 0.039330922067165375, -0.44842612743377686, 0.12001822888851166, 0.22588641941547394, 0.18959221...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#configuring-sites
Configuring Sites You can create subsites in Pimcore very easily directly in the context menu of the Document tree: That's basically all. Note: Of course, your server setup (VHost, ServerAlias) must be configured properly so that all the requests for all the domains are delegated to Pimcore. Now also the routing functionalities Custom Routes and Redirects can be configured site specific. Also, lots of other Pimcore tools and functionalities like Glossary, Tag & Snippet Management, Marketing Settings (Google Analytics, Google Search Console, Google Tag Manager) and Website Settings are site specific.
Configuring Sites
[ -0.09732789546251297, -0.2568106949329376, -0.19576425850391388, 0.13493593037128448, -0.048005230724811554, -0.09568366408348083, 0.10476629436016083, -0.16782422363758087, -0.35785776376724243, 0.041801147162914276, -0.5514948964118958, 0.13648968935012817, 0.06613898277282715, 0.4688997...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#sites-in-your-code
Sites in your Code
Sites in your Code
[ -0.16696204245090485, -0.2415039837360382, -0.43480798602104187, 0.051910728216171265, 0.21126864850521088, -0.08356911689043045, 0.26670268177986145, 0.07753976434469223, 0.1893158107995987, 0.03414995223283768, -0.06915581971406937, 0.13725289702415466, -0.011674582958221436, 0.272397428...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#check-if-current-request-is-inside-a-subsite
Check if Current Request is Inside a Subsite if(\Pimcore\Model\Site::isSiteRequest()) { /* ... */ } {% if pimcore_site_is_request() %} {# ... #} {% endif %}
Check if Current Request is Inside a Subsite
[ -0.21815983951091766, -0.6608775854110718, -0.10996118187904358, 0.06901872903108597, -0.028018003329634666, -0.2429048717021942, -0.00994737260043621, 0.1896900236606598, -0.14998985826969147, -0.08629991859197617, -0.30590179562568665, 0.05937865376472473, 0.07082462310791016, 0.19686517...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#working-with-the-navigation-helper
Working with the Navigation Helper See Navigation for more information.
Working with the Navigation Helper
[ -0.021084079518914223, -0.43999138474464417, -0.32326799631118774, -0.27041685581207275, 0.0011610436486080289, -0.2608201503753662, 0.2559891939163208, 0.05402624234557152, -0.06033715233206749, 0.21538110077381134, -0.14885196089744568, 0.09881656616926193, -0.015427011996507645, 0.06664...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#getting-the-full-path-of-a-document-inside-a-subsite-request
Getting the full path of a document inside a subsite-request $document->getRealFullpath(); // returns the path including the site-root $document->getFullPath(); // returns the path relative to the site-root document.getRealFullpath() {# returns the path including the site-root #} document->getFullPath() {# returns the path relative to the site-root #}
Getting the full path of a document inside a subsite-request
[ -0.053851936012506485, -0.7429264783859253, -0.14831170439720154, 0.23863761126995087, -0.2770279347896576, -0.030458617955446243, -0.21175073087215424, 0.36657968163490295, -0.33361080288887024, 0.0766473263502121, -0.06504513323307037, -0.17446602880954742, 0.13220611214637756, -0.441089...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#getting-the-root-document-of-the-current-site
Getting the root-document of the current site if (\Pimcore\Model\Site::isSiteRequest()) { $site = \Pimcore\Model\Site::getCurrentSite(); $navStartNode = $site->getRootDocument(); } else { $navStartNode = \Pimcore\Model\Document::getById(1); } {% if pimcore_site_is_request() %} {% set site = pimcore_site_current() %} {% set navStartNode = site.getRootDocument() %} {% else %} {% set navStartNode = pimcore_document(1) %} {% endif %}
Getting the root-document of the current site
[ -0.46470898389816284, -0.572576105594635, -0.12577632069587708, 0.2319667786359787, -0.13900047540664673, -0.28750675916671753, -0.17827799916267395, 0.3645143508911133, -0.2533985376358032, 0.06787147372961044, -0.010994240641593933, 0.1033940389752388, 0.1974395215511322, 0.1098894178867...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#some-other-tools
Some other Tools The functionality should be pretty self-explanatory: \Pimcore\Tool\Frontend::getSiteForDocument($document); \Pimcore\Tool\Frontend::isDocumentInCurrentSite($document); \Pimcore\Tool\Frontend::isDocumentInSite($site, $document);
Some other Tools
[ -0.5097508430480957, -0.1872478425502777, -0.2067045122385025, 0.12162001430988312, -0.3111474812030792, -0.12386350333690643, 0.15201085805892944, 0.3599691689014435, -0.07149973511695862, 0.09871086478233337, 0.054777681827545166, 0.2046048939228058, -0.09885445237159729, -0.174131944775...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs/Working_with_Sites#document-preview-navigation-with-sites
Document Preview Navigation with Sites Please keep in mind that when previewing documents that have links to different Sites, the navigation may not be working properly due the Iframe Content Security Policies and Cross-origin resource sharing (CORS) policy, please set your own security rules accordingly to your own needs.
Document Preview Navigation with Sites
[ -0.10926574468612671, -0.39511603116989136, -0.10572780668735504, -0.12549526989459991, -0.1771497279405594, -0.06029927730560303, 0.20116916298866272, 0.2735864222049713, 0.07540269196033478, -0.16542145609855652, -0.2763553559780121, -0.014966210350394249, 0.3054650127887726, -0.13809196...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#routing-and-urls
Routing and URLs
Routing and URLs
[ 0.24490521848201752, -0.26720818877220154, -0.24373871088027954, 0.05463197082281113, 0.022255150601267815, -0.41734254360198975, 0.21065062284469604, -0.19015271961688995, -0.38769304752349854, -0.10528974235057831, 0.06638730317354202, 0.027659965679049492, 0.010537129826843739, 0.099638...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#introduction
Introduction Routing defines which requests are delegated to which controller based on the URL they are sent to. Therefore, routing is an essential part in each MVC web application. Beside the pure technical aspect, (which controller is called) there are several other manners like URL structure and hierarchy, SEO and multi domain sites that need to be considered in combination with routing. Knowing how routing works in Pimcore/Symfony is essential to understand how an application can be implemented and how routes actually work. Technically the entire routing process is based on the Symfony routing. In addition to the default routing provided by Symfony (which is of course used as well), Pimcore has some special routing capabilities for documents, custom routes, multi-site support and redirects.
Introduction
[ 0.27117303013801575, -0.4609962999820709, -0.08050622045993805, 0.03778989613056183, -0.15087096393108368, -0.35229772329330444, -0.09769017994403839, -0.22080719470977783, -0.34748420119285583, 0.016709979623556137, -0.03019978478550911, 0.14829571545124054, 0.2617577910423279, -0.1440620...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#routing-in-pimcore
Routing in Pimcore In Pimcore, there are several ways how controllers can be reached. These routes are processed in a specific priority order as described below.
Routing in Pimcore
[ 0.04205528274178505, -0.3048032224178314, -0.13545285165309906, 0.190929114818573, 0.07609950751066208, -0.5141034722328186, -0.01800956018269062, -0.35084930062294006, -0.39769604802131653, 0.1284172683954239, -0.1784772425889969, 0.380712628364563, 0.3859345316886902, 0.03786413744091987...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#1.-system--symfony-routes:
1. System / Symfony Routes: Pimcore defines a few system routes that are required for Pimcore base functionality like the admin user-interface and may also other routes provided by custom bundles. These routes are just standard Symfony routes and have the highest priority. To get a list of all configured Symfony routes, please use Symfony's router debugger on the command line: ./bin/console debug:router
1. System / Symfony Routes:
[ 0.041596684604883194, -0.2683449685573578, -0.041286591440439224, 0.09688711166381836, -0.05697433650493622, -0.17162254452705383, 0.0912289097905159, -0.15378080308437347, -0.2173077017068863, -0.03852575272321701, -0.07228152453899384, 0.43361696600914, 0.2915974259376526, -0.00968512520...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#2.-redirects-with-priority-99:
2. Redirects with Priority 99: Redirects with priority 99 come second in the processing priority. See Redirects for details.
2. Redirects with Priority 99:
[ 0.22630122303962708, -0.26353222131729126, -0.25586551427841187, -0.01095727737993002, -0.07266200333833694, -0.2912117838859558, 0.13749758899211884, -0.11024803668260574, -0.2452125996351242, -0.05668342858552933, 0.005064709112048149, -0.016355475410819054, 0.35665151476860046, 0.330583...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#3.-pimcore-documents-and-pretty-urls:
3. Pimcore Documents and Pretty URLs: The path of Pimcore Documents also defines its public URL. In addition to the path, so called pretty URLs can be defined for individual documents. The Document path and pretty URLs come third in the processing priority. See Documents and Pretty URLs for details.
3. Pimcore Documents and Pretty URLs:
[ 0.07743935286998749, -0.06870400905609131, -0.0912775918841362, -0.014603902585804462, -0.09053616970777512, -0.5339004397392273, 0.05263030156493187, -0.15967024862766266, -0.5710464715957642, -0.09095486253499985, 0.01423244271427393, 0.35546573996543884, 0.1989082396030426, -0.129390105...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#4.-url-slugs-of-data-objects
4. URL Slugs of Data Objects With the special data type URL Slug URLs for data objects can be defined. These need to be unique and are evaluated in the fourth priority for the current site. See URL Slug for details.
4. URL Slugs of Data Objects
[ 0.29413795471191406, -0.15872952342033386, -0.02852286957204342, 0.16721516847610474, 0.11762291193008423, -0.24287836253643036, 0.27830520272254944, -0.23541197180747986, -0.20694872736930847, -0.1949482262134552, -0.2326475977897644, 0.022789152339100838, 0.10801763087511063, 0.173076748...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#5.-static-routes--custom-routes:
5. Static Routes / Custom Routes: When your application has functionality where there is no Pimcore Document necessary (e.g. product lists, detail pages, cart pages or checkout process, ...), Custom Routes allow the definition of URL patterns that are delegated to specific controllers. Custom Routes come fifth in the processing priority. See Custom Routes for details.
5. Static Routes / Custom Routes:
[ 0.2301548719406128, -0.48087406158447266, -0.09694365411996841, -0.21380004286766052, -0.15452846884727478, -0.40849724411964417, 0.06119983643293381, -0.017140371724963188, -0.14526008069515228, -0.15057247877120972, 0.18386736512184143, 0.48726245760917664, 0.1240500807762146, -0.0667925...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#6.-redirects:
6. Redirects: All Redirects with priority lower than 99 come six in the processing priority and once again processed based on their configured priority. See Redirects for details.
6. Redirects:
[ 0.23855231702327728, -0.31319496035575867, -0.2561320960521698, 0.022714801132678986, 0.06030035763978958, -0.39172038435935974, 0.0444910004734993, -0.10381963849067688, -0.19075211882591248, -0.08722402155399323, -0.030771654099225998, -0.01795879378914833, 0.31496691703796387, 0.1987101...
https://pimcore.com/docs/platform//Pimcore/MVC/Routing_and_URLs#multi-domain-sites
Multi domain sites The routing process also supports multi domain sites. See Working with Sites for more details on that.
Multi domain sites
[ -0.09419845789670944, -0.23526997864246368, -0.2207578718662262, 0.09831590950489044, 0.03171718493103981, -0.3158798813819885, 0.36726894974708557, -0.24244272708892822, -0.06422708928585052, -0.014247783459722996, -0.15050777792930603, -0.09100253134965897, 0.143389493227005, 0.540391802...
https://pimcore.com/docs/platform//Pimcore/MVC#mvc-in-pimcore
MVC in Pimcore In terms of sending output to the frontend, Pimcore follows the MVC pattern. Therefore it is crucial to know the fundamentals about the pattern in general and the specifics in combination with Pimcore. MVC is a software design pattern for web applications and separates the code into the following components: Model - defines basic functionality like data access routines, business, etc. View - defines what is presented to the user (the "template") Controller - Controllers bring all the patterns together, they manipulate models, decide which view to display, etc. If you don't know the MVC pattern please read this article first. The MVC module of Pimcore is built on top of Symfony. If you are new to Symfony you can read about controllers in the Symfony manual. With this knowledge learning Pimcore will be much easier and faster.
MVC in Pimcore
[ -0.17377576231956482, -0.45743945240974426, -0.18906018137931824, 0.01718609221279621, -0.0023052366450428963, -0.38059213757514954, -0.09145281463861465, 0.09640831500291824, -0.181397944688797, 0.12972737848758698, -0.06232978776097298, 0.4668731093406677, 0.13924455642700195, 0.30628556...
https://pimcore.com/docs/platform//Pimcore/MVC#basic-file-structure-and-naming-conventions
Basic file structure and naming conventions The most common module for working within the MVC in your Pimcore project is the App. So the most frequently used folders and files concerning the MVC within the website module are the following: Path Description Example /src/Controller The controllers directory eg. ContentController.php /templates/ The view (template) directory, the naming (sub folders and file names) follows also the naming-convention of Symfony (/templates/[controller]/[action].html.twig) All Pimcore plugins and other modules follow the same pattern. The following sub chapters provide insight into details of the Pimcore MVC structure and explain the topics Controller Template Routing
Basic file structure and naming conventions
[ 0.17434753477573395, -0.19812233746051788, -0.13127931952476501, 0.22930805385112762, 0.13220861554145813, -0.13482066988945007, -0.05143825337290764, 0.13326193392276764, -0.2508140802383423, -0.03764835372567177, -0.1415400505065918, 0.2947496175765991, 0.23213376104831696, 0.06766576319...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#create-your-own-bricks
Create Your Own Bricks
Create Your Own Bricks
[ -0.03639882057905197, -0.27548179030418396, -0.312120258808136, 0.24210144579410553, -0.061127230525016785, -0.07834088057279587, 0.6364782452583313, 0.013175375759601593, 0.3909286558628082, 0.48894283175468445, -0.2533031404018402, 0.3438872694969177, -0.3105381727218628, 0.0960686802864...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#architecture-of-a-brick
Architecture of a Brick A brick is an instance of Pimcore\Extension\Document\Areabrick\AreabrickInterface which can either be auto-loaded by saving the brick to a special namespace inside your bundle or by defining the brick as a service and adding it to the list of available bricks through a DI tag. The brick class is the only mandatory file for a brick, however most bricks will at least implement a view template which is rendered in frontend and editmode. The templates itself are normal templates which are passed to the rendering engine. Therefore you can use all existing templating extensions and Pimcore editables.
Architecture of a Brick
[ -0.20242489874362946, -0.10539644956588745, -0.07621662318706512, 0.20263123512268066, 0.23429596424102783, 0.018108604475855827, 0.42964619398117065, 0.05723061040043831, 0.28545740246772766, 0.2212754189968109, -0.24419835209846497, 0.4630385637283325, -0.057764437049627304, 0.0260283593...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#brick-registration
Brick registration A brick will be registered on the system and is represented by a brick ID which has to be unique throughout the system. If a brick ID is registered twice (e.g. by multiple bundles), an error will be raised. The simple way to register a brick is to just save it to a special namespace Document\Areabrick inside your bundle. Every bundle will be scanned for classes implementing AreabrickInterface and all found bricks will be automatically registered to the system. The brick ID will be built from the class name of the implementing class by converting the class name to dashed case. For example a brick named MyCustomAreaBrick will be automatically registered as my-custom-area-brick. A basic brick implementation could look like the following. As it is defined in the special namespace, Pimcore will implicitely auto-create a service app.area.brick.iframe and register it on the areabrick manager with the ID iframe. <?php namespace App\Document\Areabrick; use Pimcore\Extension\Document\Areabrick\AreabrickInterface; class Iframe implements AreabrickInterface { // implementing class methods } Please note that you need to clear the cache after you added a brick to the special namespace. If you need more control over the brick instance (e.g. because your brick has dependencies on other services or you want to specify the brick ID manually), you can add the service definition yourself and tag the service with the DI tag pimcore.area.brick. Bricks defined manually will be excluded from the auto-registration, even if they're defined in the special namespace. Let's define our brick as above, but assume it needs access to a logger instance: # a service.yaml file defining services services: App\Document\Areabrick\Iframe: arguments: ['@logger'] tags: - { name: pimcore.area.brick, id: iframe } This will register the brick as above, but you have control over the brick ID and are able to make use of the container for dependencies. Although it might be tempting to overwrite the getId() method in your bricks, please make sure the brick always refers to the ID which is set via setId($id) when the brick is registered. Overriding getId() won't affect the brick ID as it is registered on the system as bricks are lazy-loaded. The areabrick manager will set the registered ID when the brick instance is fetched.
Brick registration
[ -0.34575629234313965, -0.13596518337726593, 0.05294492840766907, 0.293334424495697, -0.0009502025786787271, -0.10608353465795517, 1.0220924615859985, -0.147134467959404, 0.27592477202415466, 0.2553023397922516, 0.0405852384865284, 0.1598571389913559, -0.2806943953037262, -0.126094534993171...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#brick-template-auto-discovery
Brick template auto discovery For convenience, you can create a new brick by extending Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick to make use of template auto-discovery (thus, needing a minimum of code to get started). The template area brick implements the TemplateAreabrickInterface which defines the following methods you can use to control template auto-discovery. Please make sure your brick is defined inside a bundle as otherwise your templates can't be auto-discovered. The template location defines the base path which will be used to find your templates. It resolves to the following locations. <bundlePath> is the filesystem path of the bundle the brick resides in, <brickId> the ID of the brick as registered on the areabrick manager (see below). Location Path global templates/areas/<brickId>/ bundle <bundlePath>/Resources/views/areas/<brickId>/ for legacy (Symfony <= 4) bundle strucureor<bundlePath>/templates/areas/<brickId>/ for modern (Symfony >= 5) bundle structure Depending on the template location, the following files will be used. You can always completely control locations by implementing the methods for templates and icon yourself (see AreabrickInterface): Type Location view template <templateLocation>/view.html.twig If the brick defines an icon in the public resources directory of the bundle, the icon will be automatically used in editmode. If the icon is at another location, you can override the getIcon() method and specify an URL to be included as icon. When rendering editmode, the following location will be searched for the brick icon and is expected to be a 16x16 pixel PNG: <bundlePath>/Resources/public/areas/<brickId>/icon.png which resolves to the URL /bundles/<bundleUrl>/areas/<brickId>/icon.png when included in editmode. You can optionally implement Pimcore\Extension\Document\Areabrick\PreviewAwareInterface to add a custom html tooltip for your brick that will be shown as a tooltip when hovering over the add-brick button. Given our iframe brick defined before, the following paths will be used.
Brick template auto discovery
[ -0.31280413269996643, -0.1596442312002182, -0.10194719582796097, 0.1732415407896042, 0.029694732278585434, -0.2534570097923279, 0.5155513286590576, 0.08759774267673492, 0.14479485154151917, 0.08172069489955902, -0.19438502192497253, 0.7242740988731384, -0.08268570154905319, -0.137468338012...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#global-template-location
global template location Location Path view template templates/areas/iframe/view.html.twig icon path public/bundles/app/areas/iframe/icon.png icon URL /bundles/app/areas/iframe/icon.png
global template location
[ 0.10303321480751038, -0.14890912175178528, -0.13678862154483795, 0.019314579665660858, 0.10627608001232147, 0.0735502764582634, 0.38961347937583923, 0.18911610543727875, -0.20487862825393677, 0.06367889791727066, 0.01489910390228033, 0.22687354683876038, 0.19153745472431183, -0.03648849576...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#bundle-template-location
bundle template location The icon path and URL are the same as above, but the view scripts are expected inside the bundle. Location Path view template templates/areas/iframe/view.html.twig
bundle template location
[ 0.12202702462673187, -0.1778068095445633, -0.048086293041706085, 0.002684616018086672, 0.11173039674758911, 0.0013207728043198586, 0.4180357754230499, 0.13739901781082153, 0.05008790269494057, -0.13909801840782166, -0.0928269550204277, 0.39112451672554016, 0.08358292281627655, 0.0942058339...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#how-to-create-a-brick
How to Create a Brick Let's suppose, that our iframe brick defined above is responsible for generating an <iframe> containing contents from a specified URL in the editmode. First of all, let's update the class to add metadata for the extension manager, to make use of template auto-discovery and to load the view template from templates instead of the bundle directory: <?php // src/Document/Areabrick/Iframe.php namespace App\Document\Areabrick; use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick; class Iframe extends AbstractTemplateAreabrick { public function getName(): string { return 'IFrame'; } public function getDescription(): string { return 'Embed contents from other URL (websites) via iframe'; } public function needsReload(): bool { // optional // here you can decide whether adding this bricks should trigger a reload // in the editing interface, this could be necessary in some cases. default=false return false; } } Let's create a view as next step. Views behave exactly as native controller views and you have access to the current document, to editmode and to editables and templating helpers as everywhere else. In addition there's a instance variable on the view which gives you access to the brick instance. A info variable (see below) gives you access to brick metadata. /* templates/areas/iframe/view.html.twig */ {% set urlField = pimcore_input('iframe_url') %} {% set widthField = pimcore_numeric('iframe_width') %} {% set heightField = pimcore_numeric('iframe_height') %} {% set transparentField = pimcore_checkbox('iframe_transparent') %} {% if editmode %} <div> <h2>IFrame</h2> <div> URL: {{ urlField }} </div> <br/> <b>Advanced Configuration</b> <div> Width: {{ widthField }}px (default: 100%) </div> <div> Height: {{ heightField }}px (default: 400px) </div> <div> Transparent: {{ transparentField }} (default: false) </div> </div> {% else %} {% if not urlField.isEmpty() %} {% set transparent = 'false' %} {% set width = '100%' %} {% set height = '400' %} {% if not widthField.isEmpty() %} {% set width = widthField.data %} {% endif %} {% if not heightField.isEmpty() %} {% set height = heightField.data %} {% endif %} {% if transparentField.isChecked() %} {% set transparent = 'true' %} {% endif %} <iframe src="{{ urlField }}" width="{{ width }}" height="{{ height }}" allowtransparency="{{ transparent }}" frameborder="0"></iframe> {% endif %} {% endif %} Now you should be able to see your brick in the list of available bricks on your areablock: In editmode you can see the configuration for the Iframe brick:
How to Create a Brick
[ -0.10075387358665466, -0.21053536236286163, 0.02393392287194729, 0.047252047806978226, -0.0019450929248705506, -0.3059828579425812, 0.6375181674957275, 0.1722394824028015, 0.1450043022632599, 0.21474677324295044, -0.27450448274612427, 0.630237877368927, -0.24620142579078674, -0.13601948320...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#the-brick-info-object
The Brick info-object Brick views and methods will have access to an Info object containing metadata about the current brick. It is exposed as info variable on views and passed to brick methods as argument. Many methods exist for historical reasons, but a couple of methods could be useful when implementing your own bricks. Method Description $info->getEditable() Returns the editable rendering the brick $info->getDocument() Retrieve the document $info->getDocumentElement($name) Retrieve the editable tag from document $info->getRequest() Returns the current request $info->getIndex() Returns the current index inside the areablock $info->getParam($name) Retrieve a param passed by globalParams or params config option $info->getParams() Retrieve all params passed by globalParams or params config option
The Brick info-object
[ -0.22032995522022247, -0.039030853658914566, -0.15293578803539276, 0.3012522757053375, -0.10316351801156998, -0.17731116712093353, 0.49744775891304016, 0.2441447377204895, 0.3509911000728607, 0.4040381908416748, -0.23697473108768463, 0.48167794942855835, -0.11142411828041077, -0.1697101891...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#editable-dialog-(since-6.8)
Editable Dialog (since 6.8) Sometimes it is necessary to gather some more optional data or provide some configuration options for a brick, which shouldn't be visible by default. For those scenarios the editable dialog is the right tool. The editable dialog is basically a configurable editing interface where you can use all supported editables in a structured layout in the context of the current brick. The editing interface is configured by implementing the EditableDialogBoxInterface on your brick class and by providing a simple config array.
Editable Dialog (since 6.8)
[ -0.17647595703601837, -0.1682964563369751, -0.1391344666481018, -0.0894562378525734, -0.09785395860671997, 0.17489615082740784, 0.44087329506874084, 0.20884142816066742, 0.17346806824207306, 0.2948152720928192, -0.5631638765335083, 0.5324956774711609, -0.1337405890226364, -0.05234593525528...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#simple-example-config
Simple Example Config <?php namespace App\Document\Areabrick; use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration; use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface; use Pimcore\Model\Document; use Pimcore\Model\Document\Editable\Area\Info; class WysiwygWithImages extends AbstractAreabrick implements EditableDialogBoxInterface { /** * {@inheritdoc} */ public function getName(): string { return 'WYSIWYG w. Images'; } public function getEditableDialogBoxConfiguration(Document\Editable $area, ?Info $info): EditableDialogBoxConfiguration { $config = new EditableDialogBoxConfiguration(); $config->setWidth(600); //$config->setReloadOnClose(true); $config->setItems([ [ 'type' => 'input', 'label' => 'Some additional Text', // labels are optional 'name' => 'myDialogInput' ], [ 'type' => 'checkbox', 'name' => 'myDialogCheckbox', 'label' => 'This is the checkbox label', 'description' => 'This is a description for myDialogCheckbox' // descriptions are optional ], [ 'type' => 'date', 'name' => 'myDialogDate' ] ]); return $config; } }
Simple Example Config
[ -0.2719023525714874, -0.2372477799654007, -0.12667430937290192, 0.23711848258972168, 0.004282412584871054, -0.1506672203540802, 0.44921571016311646, 0.2185109406709671, -0.02498181164264679, 0.22492022812366486, -0.13957764208316803, 0.3375398516654968, -0.09706888347864151, -0.02618009969...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#advaned-example-config-using-layouts
Advaned Example Config using Layouts It is also possible to use tab panels in your configuration. <?php namespace App\Document\Areabrick; use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration; use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface; use Pimcore\Model\Document; use Pimcore\Model\Document\Editable\Area\Info; class WysiwygWithImages extends AbstractAreabrick implements EditableDialogBoxInterface { /** * {@inheritdoc} */ public function getName(): string { return 'WYSIWYG w. Images'; } public function getEditableDialogBoxConfiguration(Document\Editable $area, ?Info $info): EditableDialogBoxConfiguration { $config = new EditableDialogBoxConfiguration(); $config->setWidth(600); $config->setItems([ 'type' => 'tabpanel', 'items' => [ [ 'type' => 'panel', 'title' => 'Tab 1', 'items' => [ [ 'type' => 'wysiwyg', 'label' => 'Some additional Text', 'name' => 'myDialogWysiwyg' ], [ 'type' => 'video', 'name' => 'myDialogVideo' ], [ 'type' => 'textarea', 'name' => 'myDialogTextarea' ], [ 'type' => 'table', 'name' => 'myDialogTable' ], [ 'type' => 'snippet', 'name' => 'myDialogSnippet' ], [ 'type' => 'select', 'name' => 'myDialogSelect', 'config' => [ 'store' => [ ['foo', 'Foo'], ['bar', 'Bar'], ['baz', 'Baz'], ] ] ], [ 'type' => 'numeric', 'name' => 'myDialogNumber' ], [ 'type' => 'multiselect', 'name' => 'myDialogMultiSelect', 'config' => [ 'store' => [ ['foo', 'Foo'], ['bar', 'Bar'], ['baz', 'Baz'], ] ] ], [ 'type' => 'checkbox', 'name' => 'myDialogCheckbox', 'label' => 'This is the checkbox label 😸', ], [ 'type' => 'input', 'name' => 'myDialogInput' ] ] ], [ 'type' => 'panel', 'title' => 'Tab 2', 'items' => [ [ 'type' => 'input', 'name' => 'myNumber3' ], [ 'type' => 'link', 'name' => 'myDialogLink' ], [ 'type' => 'image', 'name' => 'myDialogImage' ], [ 'type' => 'embed', 'name' => 'myDialogEmbed' ], [ 'type' => 'date', 'name' => 'myDialogDate' ] ] ], [ 'type' => 'panel', 'title' => 'Tab 3', 'items' => [ [ 'type' => 'renderlet', 'name' => 'myDialogRenderlet' ], [ 'type' => 'relations', 'name' => 'myDialogRelations' ], [ 'label' => 'Just a single relation 😹', 'type' => 'relation', 'name' => 'myDialogRelation' ], [ 'type' => 'pdf', 'name' => 'myDialogPdf' ] ] ] ] ]); return $config; } }
Advaned Example Config using Layouts
[ -0.34278103709220886, -0.15032696723937988, -0.09673606604337692, 0.014850436709821224, 0.012115519493818283, -0.10353333503007889, 0.6335772275924683, 0.1610749363899231, -0.07889367640018463, 0.1270529329776764, -0.3301455080509186, 0.3445609211921692, -0.015370353125035763, 0.0560710132...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#accessing-data-of-the-editable-dialog
Accessing Data of the Editable Dialog The editables in the dialog are just normal editables, there's not difference to editables which are defined via the template. So can either use them as well in the template or access them in your custom code.
Accessing Data of the Editable Dialog
[ 0.1464465707540512, -0.044756289571523666, -0.207441046833992, 0.2509714961051941, -0.0006790468469262123, 0.16126298904418945, 0.3211361765861511, 0.060299962759017944, -0.26923659443855286, 0.1448802351951599, -0.6247257590293884, 0.4991973638534546, -0.0857139378786087, 0.18062771856784...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#methods-on-the-brick-class
Methods on the brick class Sometimes a brick is more than just a view-script and contains some functionality which shouldn't be directly in the view. In this case you can use the action() and postRenderAction() method on the brick class which both get the info object as parameter. The action() method is no real controller action, it is just a little helper to get some logic and code out of the view. However, you can use the action method to prepare data for the view (for example parse request params). You can return a Response object from action() and postRenderAction() and this response will be sent back to the client. If you need to influence the HTML open and close tag, you can do so by customizing getHtmlTagOpen() and getHtmlTagClose() (see example below). <?php namespace App\Document\Areabrick; use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick; use Pimcore\Model\Document\Editable\Area\Info; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; class Iframe extends AbstractTemplateAreabrick { // other methods defined above // public function action(Info $info): ?RedirectResponse { $myVar = $info->getRequest()->get('myParam'); $info->setParam('myVar', $myVar); // optionally return a response object if ('POST' === $info->getRequest()->getMethod()) { return new RedirectResponse('/foo'); } return null; } // OPTIONAL METHODS // executed after a brick is rendered public function postRenderAction(Info $info): ?Response { } // returns a custom html wrapper element (return an empty string if you don't want a wrapper element) public function getHtmlTagOpen(Info $info): string { return '<span class="customWrapperDiv">'; } public function getHtmlTagClose(Info $info): string { return '</span>'; } }
Methods on the brick class
[ -0.24137549102306366, -0.18946613371372223, -0.07223688066005707, 0.11533503234386444, 0.005167617462575436, -0.4652203917503357, 0.6189744472503662, 0.24426354467868805, 0.3020726144313812, 0.14290256798267365, -0.08579296618700027, 0.44465020298957825, 0.14171791076660156, 0.140161439776...
https://pimcore.com/docs/platform//Pimcore/Documents/Editables/Areablock/Bricks#examples
Examples You can find many examples in the demo package.
Examples
[ -0.22597678005695343, -0.4891335070133209, -0.39180588722229004, -0.15812963247299194, -0.10200036317110062, -0.3051791787147522, 0.42629116773605347, -0.018142569810152054, -0.02519751712679863, 0.39726489782333374, 0.06915833801031113, 0.22191603481769562, -0.03654981032013893, 0.1510268...