3

So the way Twig works is that it populates a Twig Environment with a context of global variables. Then any time a template includes another template, the context is passed down to it. So if you want something to be globally available you have to insert it into the Twig environment before Twig is used, for it to be truly globally available. You can do that ...


2

those CP files are included by CpAsset asset bundle. if your plugin asset bundle depends on CpAsset: class YourPluginAsset extends AssetBundle { public function init() { $this->sourcePath = __DIR__ . '/dist'; $this->depends = [ CpAsset::class, ] //.... } } and if you register your plugin asset in ...


2

UIDs are not yet usable in queries. You would need to extract the UID of the section from the string then fetch the sectionId to use in your query. Something like this: {% for tab in entry.fieldLayout.tabs %} {{ tab.name }} {% for field in tab.getFields() %} <label for="{{ field.handle }}">{{ field.name }}</label> <br> ...


2

You can use the instance of test (docs) {% if field is instance of ('craft\\fields\\PlainText') %} or use className (docs). {% if field.className == 'craft\\fields\\PlainText' %} In full: {% for tab in entry.fieldLayout.tabs %} <div class="form__row"> <h3>{{ tab.name }}</h3> </div> {% for field in tab....


1

I found a solution: {% include "_private/partials/matrix" with {blocks: entry.bodyContent.typeId(null).all()} %} This fetches all Matrixobjects from any type. So it works now. But I don't undestand, why this is necessary. Maybe its because I used for my first project this Blogstarter. Maybe there are some relicts from craft2 inside. So I have the ...


1

Without seeing the code of your template _private/partials/matrix it's not easy to help you. Maybe you need to check the block type first. I usually do that with a switch and have a different partial for each block. So your template _private/partials/matrix could look something like this: {% for block in blocks %} {% switch block.type %} {% case "...


1

Use the Kint plugin to spit out the current tab to the JS debug console: {% for tab in layout.tabs %} {% if tab.name == "Detaljer" %} {{ j(tab) }} {% for field in tab.getFields %} You will see that the structure of the tab-object actually contains the UI-elements as well: Instead of looping tab.getFields, loop tab.elements: ...


1

Finally found the answer after much time spent on it. The $(this).serialize() loses the file input - and can't submit. Updated ajax submit to $.ajax({ type: 'POST', url: url, data: new FormData(this) , dataType : 'json', // changing data type to json processData: false, contentType: false, success: function (response) { // ...


Only top voted, non community-wiki answers of a minimum length are eligible