This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Dear october fan, I try to extend the StaticPage to have the ability to add a PDF file per page.
I followed these two hints : https://www.codesd.com/item/october-cms-extend-the-page-to-have-an-associated-image.html https://octobercms.com/forum/post/extending-page-plugin-with-fileupload
In my code I first tried this : Plugin/Rainlab/pages/Plugin.php
public function register() {
Event::listen('backend.form.extendFields', function($widget) {
if (!$widget->model instanceof \RainLab\Pages\Classes\Page) {
return;
}
$widget->addTabFields([
'settings[pdf_file]' => [
'label' => 'Document PDF',
'tab' => 'PDF',
'field' => 'settings[pdf_file]',
'type' => 'mediafinder',
'comment' => 'PDF url is available via the page settings under the name of pdf_file (And the value is available via this.page.pdf_file Twig value)'
],
], 'primary');
});
}
But it does not save the PDF file within the page ! So I tried with the Uploadfile, like this :
public function register() {
Event::listen('backend.form.extendFields', function($widget) {
if (!$widget->model instanceof \RainLab\Pages\Classes\Page) {
return;
}
$widget->addTabFields([
'pdf_file' => [
'label' => 'Document PDF',
'tab' => 'PDF',
/**'field' => 'settings[pdf_file]', */
'type' => 'fileupload',
'mode' => 'file',
'fileTypes' => 'pdf',
'comment' => 'PDF url is available via the page settings under the name of pdf_file (And the value is available via this.page.pdf_file Twig value)'
],
], 'primary');
});
And it raise an error. "Call to undefined method October\Rain\Halcyon\Builder::hasRelation()" on line 782 of /Applications/MAMP/htdocs/october.dev/vendor/october/...
So I tried to set this in /plugins/rainlab/pages/classes/Page.php
public $attachOne = [
'pdf_file' => 'System\Models\File',
'delete' => true
];
But it does not help at all.
Do you have any clue how to solve this?
Thanks a lot in advance. Best regards, joe
jowa said: bullet force
Dear october fan, I try to extend the StaticPage to have the ability to add a PDF file per page.
I followed these two hints : https://www.codesd.com/item/october-cms-extend-the-page-to-have-an-associated-image.html https://octobercms.com/forum/post/extending-page-plugin-with-fileupload
In my code I first tried this : Plugin/Rainlab/pages/Plugin.php
public function register() { Event::listen('backend.form.extendFields', function($widget) { if (!$widget->model instanceof \RainLab\Pages\Classes\Page) { return; } $widget->addTabFields([ 'settings[pdf_file]' => [ 'label' => 'Document PDF', 'tab' => 'PDF', 'field' => 'settings[pdf_file]', 'type' => 'mediafinder', 'comment' => 'PDF url is available via the page settings under the name of pdf_file (And the value is available via this.page.pdf_file Twig value)' ], ], 'primary'); }); }
But it does not save the PDF file within the page ! So I tried with the Uploadfile, like this :
public function register() { Event::listen('backend.form.extendFields', function($widget) { if (!$widget->model instanceof \RainLab\Pages\Classes\Page) { return; } $widget->addTabFields([ 'pdf_file' => [ 'label' => 'Document PDF', 'tab' => 'PDF', /**'field' => 'settings[pdf_file]', */ 'type' => 'fileupload', 'mode' => 'file', 'fileTypes' => 'pdf', 'comment' => 'PDF url is available via the page settings under the name of pdf_file (And the value is available via this.page.pdf_file Twig value)' ], ], 'primary'); });
And it raise an error. "Call to undefined method October\Rain\Halcyon\Builder::hasRelation()" on line 782 of /Applications/MAMP/htdocs/october.dev/vendor/october/...
So I tried to set this in /plugins/rainlab/pages/classes/Page.php
public $attachOne = [ 'pdf_file' => 'System\Models\File', 'delete' => true ];
But it does not help at all.
Do you have any clue how to solve this?
Thanks a lot in advance. Best regards, joe
I'm having the same problem, anyone knows how to get the uploaded image link?
1-3 of 3