TC
Twill CMS16mo ago
Mateo

twill metadata

Hello everyone do you know any package to setup SEO from dashboard compatible with Twill 3 ? Or any way how to render seo fieldset in Pages with twill 3 https://github.com/cwsdigital/twill-metadata
GitHub
GitHub - cwsdigital/twill-metadata: SEO Metadata Package for Twill CMS
SEO Metadata Package for Twill CMS. Contribute to cwsdigital/twill-metadata development by creating an account on GitHub.
11 Replies
ifox
ifox16mo ago
Hi @mathew_d you can use this package by using a BladePartial field in your Twill 3 controller
Mateo
MateoOP16mo ago
Hello @ifox.dev I tried a lot to make something apears in bottom of my pages but it seems dificult for me in twill 3 so you are saying to modify admin controller or normal controller ? for this default controller PageController
*/
public function getForm(TwillModelContract $model): Form
{
$form = parent::getForm($model);

$form->add(
Input::make()->name('description')->label('Description')->translatable()
);

$form->add(
Medias::make()->name('cover')->label('Cover image')
);

$form->add(
BlockEditor::make()->blocks(['accordion'])
);
$form->add(
BladePartial::make()->view('admin.pages.form')
);

return $form;
}
*/
public function getForm(TwillModelContract $model): Form
{
$form = parent::getForm($model);

$form->add(
Input::make()->name('description')->label('Description')->translatable()
);

$form->add(
Medias::make()->name('cover')->label('Cover image')
);

$form->add(
BlockEditor::make()->blocks(['accordion'])
);
$form->add(
BladePartial::make()->view('admin.pages.form')
);

return $form;
}
I did this but nothing @chrispymm@pauldwight can you give me any suggestion please
pauldwight
pauldwight16mo ago
We use it like this for Twill3
public function getForm(TwillModelContract $model): Form
{
$form = parent::getForm($model);

// publish the twill-metadata view then pass in the additional data from the config - we tend to have the SEO in it's own fieldset hence the below.
$form->addFieldset(
Fieldset::make()->title('SEO')->id('metadata')
->fields([
BladePartial::make()->view('twill.fields.metadata')
->withAdditionalParams([
'metadata_card_type_options' => config('metadata.card_type_options'),
'metadata_og_type_options' => config('metadata.opengraph_type_options'),
])
])
);

return $form;
}
public function getForm(TwillModelContract $model): Form
{
$form = parent::getForm($model);

// publish the twill-metadata view then pass in the additional data from the config - we tend to have the SEO in it's own fieldset hence the below.
$form->addFieldset(
Fieldset::make()->title('SEO')->id('metadata')
->fields([
BladePartial::make()->view('twill.fields.metadata')
->withAdditionalParams([
'metadata_card_type_options' => config('metadata.card_type_options'),
'metadata_og_type_options' => config('metadata.opengraph_type_options'),
])
])
);

return $form;
}
Mateo
MateoOP16mo ago
@pauldwight now my form works but i have an dublicated seo section but by functionality it works perfect
No description
pauldwight
pauldwight16mo ago
It looks like you have 2 field sets somehow. Can you share your getForm function and the partial blade include?
Mateo
MateoOP16mo ago
yes this is the get Form and this is my blade
No description
No description
pauldwight
pauldwight16mo ago
Okay - the blade file is also including the fieldset so you can remove that part from your getForm() method so something like this...
$form->add(
BladePartial::make()->view('twill.fields.metadata')
->withAdditionalParams([
'metadata_card_type_options' => config('metadata.card_type_options'),
'metadata_og_type_options' => config('metadata.opengraph_type_options'),
])
);
$form->add(
BladePartial::make()->view('twill.fields.metadata')
->withAdditionalParams([
'metadata_card_type_options' => config('metadata.card_type_options'),
'metadata_og_type_options' => config('metadata.opengraph_type_options'),
])
);
Mateo
MateoOP16mo ago
yes it works thank you so much
alwynWymeersch
alwynWymeersch15mo ago
We've just implemented this package and we are experiencing some issues. Basically the "add new" for one of our models no longer works. It's very bizarre because it's only on 1 of our models. And overall the module DOES work... This is the error that is logged when trying to save a new model. [2023-09-04 16:20:00] local.ERROR: Illuminate\Database\Grammar::parameterize(): Argument #1 ($values) must be of type array, int given, called in laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 1022 Upon further inspection something weird is going on when the trait hasMetadata is activated. It changes the structure of the fields (probably why this error is thrown). Has anyone experienced the same issue?
No description
pauldwight
pauldwight15mo ago
@alwynWymeersch do you have the mediaParams set in your model?
public $mediasParams = [
'cover' => [
'default' => [
[
'name' => 'default',
// 'ratio' => 16 / 9,
],
],
],
];
public $mediasParams = [
'cover' => [
'default' => [
[
'name' => 'default',
// 'ratio' => 16 / 9,
],
],
],
];
alwynWymeersch
alwynWymeersch15mo ago
Hi was just about to delete this message as we have found the solution :-). Thanks for the reply though! The issue was related to this indeed. The package uses the wrong format so it would revert to it's own defaults if this was not set on the model explicitly.
Want results from more Discord servers?
Add your server