impresspages / ImpressPages

ImpressPages is php framework with admin panel. Build functional website in one hour.
http://www.impresspages.org
Other
502 stars 175 forks source link

Add image and file to WidgetSkeleton Plugin #818

Open machomaaan opened 8 years ago

machomaaan commented 8 years ago

Hi.

How can I add images an files to the Plugin "WidgetSkeleton"? I can add RichText, Text, and so on but i want to add an image with RepostoryFile. But the image doesn't appear in frontend.

So in WidgetSkeleton\AdminController.php I do this: $field = new \Ip\Form\Field\RichText( array( 'name' => 'Description', 'label' => 'Description', 'value' => empty($widgetData['Description']) ? null : $widgetData['Description'] ) ); $form->addField($field);

And in WidgetSkeleton\Widget\WidgetSkeleton\Skin\default.php I do this:

Description:

So far so good. But how can I add an image and a file?

Thank you!

maskas commented 8 years ago

First of all you have to choose between: 1 https://www.impresspages.org/docs/form-object/file and 2 https://www.impresspages.org/docs/form-object/repositoryfile or 3 Any custom your own solution

First option is if you want users to upload files. But it is up to you how to handle files after the upload as they end up laced in tmp directoyr.

Second option is good if you want those images to be uploaded by the admin. But in this case you end up with files sitting in the repository (https://www.impresspages.org/docs/repository)

The third option is if you don't want to use any existing concepts and want to do your own file handling.

machomaaan commented 8 years ago

Hi Maskas, thanks for your answer. I'll use RepositoryFile but how can I display the uploaded image in frontend? Upload the image in Backend/Admin works, but how to display this file in frontend?

Thanks alot.

jankus commented 8 years ago

See Reflections part - https://www.impresspages.org/docs/repository

machomaaan commented 8 years ago

Hmm... I don't now how to use this?! Can you help me? I don't want to resize the images... just upload the image in backend with the form (AdminController.php) and than show the display in frontend (default.php).

So how I do the php echo?

Thank you very much.

maskas commented 8 years ago

Sure you can do so. RepositoryFile docs states an example code to get URL of submitted Repository File value:

<?php ipFileUrl('file/repository/' . $submittedValue);

machomaaan commented 8 years ago

I don't get the image :(

This is in my AdminController.php :

$field = new \Ip\Form\Field\RepositoryFile( array( 'name' => 'IMAGE', 'label' => 'IMAGE', 'preview' => 'thumbnails', 'value' => empty($widgetData['IMAGE']) ? null : $widgetData['IMAGE'], 'filterExtensions' => array('jpg', 'jpeg', 'png') ) );

$form->addField($field);

maskas commented 8 years ago

The code you are using is just to make file upload to appear. How you save the submitted value and where do you display it are separate things.

machomaaan commented 8 years ago

Ok, so how can I submit the value an display it in default.php?

machomaaan commented 8 years ago

Can anybody tell me which code I've to write into AdminController.php and default.php for image upload and for file (pdf) upload? I can't manage that :(

Thank you very much.