Shopware-6-Blog-Plugin
Shopware-6-Blog-Plugin copied to clipboard
Custom Field
is there a way to add a custom field or even a custom taxonomy for blog entries like location etc.?
i'm also interested!
I've noticed the BlogEntriesDefinition
does contain support for custom fields so adding one programmatically should work, but I would rather add one through the admin panel. Would it be possible to add support for adding a custom field to blog entities and being able to edit the values for each blog through the admin panel?
@ChristopherDosin I've noticed that this issue hasn't been responded to yet. Any way you can add a response or close the issue?
customFields are available within the database already.
If you want to show some customFields, you would need to extend the current module to be able to show these inside the administration.
We might need to extend the documentation to show you how you can actually set the customFields within the administration.
I guess it's very hard to implement, because the custom field detail form (sw-custom-field-set-detail-base
) have to be aware of the sas_blog_entries
entity. But the known entities are hardcoded at custom-field.service.js
(search for $entityNameStore
). This is required to assign a custom field set to the blog entities. The only alternative is to show every available custom field set in the blog module. But I don't like this idea.
@viennt We should take a look into this for our version 2.
@timonf I am not sure how familiar you are with the customFieds / how you are using them. But you you have basically two ways. Either use these UI implemented customFields that you know from the products etc.
Or you can use them directly inside your template.
Let's say you want to extend the product view with a short description below the actual description.
Then you just call your customField
like this:
<template v-if="product.customFields">
<sw-inherit-wrapper
v-model="product.customFields.shortDescription"
:has-parent="!!parentProduct.id"
:inherited-value="parentProduct.id ? parentProduct.customFields.shortDescription : null"
>
<template #content="props">
<sw-field
type="textarea"
:map-inheritance="props"
:value="props.currentValue"
:disabled="props.isInherited || !allowEdit"
:label="$tc('sw-product.basicForm.labelShortDesc')"
:placeholder="$tc('sw-product.basicForm.placeholderShortDesc')"
@input="props.updateCurrentValue"
/>
</template>
</sw-inherit-wrapper>
</template>
The JS would be like
import template from './sw-product-basic-form.html.twig';
const {Component} = Shopware;
Component.override('sw-product-basic-form', {
template,
methods: {
createdComponent() {
this.initCustomField();
this.$super('createdComponent');
},
initCustomField() {
this.product.customFields = this.product.customFields ?? {};
this.parentProduct.customFields = this.parentProduct.customFields ?? {};
},
},
});
Hope this helps.