Hello I´m doing upload of images with vich upload and is returning the path name as.
The images were being uploaded and being displayed in the easy admin.
But then suddenly it started to not load the images anymore, and I´ve found that the destination directory was changed to ->
C:\xampp_\tmp\phpB51C.tmp
my vich mapping is like
mappings:
manchete_images:
uri_prefix: '\uploads\images\manchetes'
upload_destination: '%kernel.project_dir%/public/uploads/images/manchetes'
the images were appering normally, then suddenly start to broken to and is not creating the file upload file in the public directory
Try changing the \ in uri_prefix: '\uploads\images\manchetes' for / and try again.
Firstable as Ez mentionned you need to change the \ in uri_prefix.
Second, ther's a problem in your easy_admin configuration with the edit form.
you need to use caminhoDaImagem proprety instead of arquivoDaImagem under your form, new or edit configuration...and the file type should be changed from file to vich_file or vixh_image. ..It's already mentioned in the doc https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html#uploading-the-images-in-the-edit-and-new-views
easy_admin:
entities:
Product:
# ...
form:
fields:
- { property: 'imageFile', type: 'vich_image' }
I fixed your code you can see my PR
Related
I work with Symfony 4.2
I divided my dir structure, and every part of app is in other folder.
Ex. admin part code is in src/Admin/...
- src/Admin/Controller
etc.
When I set #Template in controller method symfony tell me to situate templates in templates/
But I want to it placed in teplates/Admin/
What I should change in config.
If is other solution than set every action path in #Template(...) ?
Taken from the docs:
# config/packages/twig.yaml
twig:
# ...
paths: ["%kernel.project_dir%/resources/views"]
https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-templates-directory
This might also be interesting for you:
https://symfony.com/doc/current/templating/namespaced_paths.html#multiple-paths-per-namespace
I'm having some trouble runnning Symfony. In fact, it can't find the default twig template. I didn't touch the code at all, juste generated my bundle and trying to access /web/app_dev.php.
My template is in
/src/OC/PlatformBundle/Resources/views/Default/index.html.twig.
Symfony looked into these locations, but not where my template actually is.
/app/Resources/views
/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form
And the DefaultController.php indexAction() looks ok :
public function indexAction(){
return $this->render("OCPlatform:Default:index.html.twig");
}
If any of you have ever faced this kind of issue or have any idea where the problem comes from, I thank you in advance for your help.
Arthur
I've same problem and i resolve it with this route :
public function indexAction(){
return $this->render("#OCPlatform/Default/index.html.twig");
}
Edit ":" with "/" and it work.
Maybe can help other developper
If you want to keep using the 'OCPlatform:Default:index.html.twig' format for templates then edit your app/config/config.yml file:
#app/config/config.yml
framework:
templating:
engines: ['twig']
This fixed my problem. You can check this link
Symfony 3.4 Use view inside my bundle
Following the docs(Symfony >=3.4) you should write the path to the template in the controller like this:
public function indexAction(){
return $this->render("#OCPlatform:Default:index.html.twig");
}
This worked for me:
return $this->render('#HomeBundle/Default/index.html.twig');
Hope it hope :)
Referencing Templates in a Bundle¶
If you need to refer to a template that lives in a bundle, Symfony uses the Twig namespaced syntax (#BundleName/directory/filename.html.twig). This allows for several types of templates, each which lives in a specific location:
#AcmeBlog/Blog/index.html.twig: <br>This syntax is used to specify a template for a specific page. The three parts of the string, each separated by a slash (/), mean the following:<br>
#AcmeBlog: is the bundle name without the Bundle suffix. This template lives in the AcmeBlogBundle (e.g. src/Acme/BlogBundle);<br>
Blog: (directory) indicates that the template lives inside the Blog subdirectory of Resources/views/;<br>
index.html.twig: (filename) the actual name of the file is index.html.twig.
In symfony 4 use this :
return $this->render("#Platform/Default/index.html.twig");
I can't find it in the documentation : Silverstripe-behat-extension
I have a feature file that has some testing scripts. Now I want to fill some test content in a temp database.
So I create a yml file that puts the content in the database.
But how do I load the yml file in my features file?
In your feature use:
Background:
Given a file "/absolute/path/my-data-fixture.yml"
I have in my template something like that
<h1>Workers {{ 'views.index.list'|trans({}, 'JordiLlonchCrudGeneratorBundle') }}</h1>
And I want to translate this but I don't know how. I guess have to create a file with translations but where save it ,how name a file and what write inside?
In app/config/config.yml I have 'translator: { fallback: "%locale%" }'
In 'symfony/app/config/parameters.yml' defined locale parameter "locale:pl"
First look at the bundle's Resources / translations folder. It looks loke this:
JordiLlonchCrudGeneratorBundle.ca.yml
JordiLlonchCrudGeneratorBundle.en.yml
JordiLlonchCrudGeneratorBundle.es.yml
Then create a file JordiLlonchCrudGeneratorBundle.pl.yml (if you want to translate to the pl local) and put it to the app/Resources/JordiLlonchCrudGeneratorBundle/translations directory.
Use one of the default translation files as a pattern for your translation, translate all text you need and save it to the pl translation file you've just created.
See also: http://symfony.com/doc/2.1/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-validation-etc
I downloaded the I18n generator package from: http://codex.wordpress.org/I18n_for_WordPress_Developers#Generating_a_POT_file. I want to generate a pot file for my created template now:
php makepot.php /home/mr/workspace/blog/wp-content/themes/myTheme/ de_DE.pot
After executing this command, I get a de_DE.pot with some the WP standard keys in. But my new keys will not be found. But if I add them to the file manually and upload it, they will be translated.
Why doesn't WordPress pick up all my keys?
I have used the poEdit in the following way.
File Menu > New Catalog
Set the language as per your need. Set utf8
Set the paths as . and ..(if you want to place your .mo file at languages folder).
Define the functions from which the strings to take( ie , _, _e, _n, _x, _ex etc).
Now save the file to your template's folder as templateName.po
Now update catalog.
Upon saving the .mo file will be generated in the same folder.
Now rename the .mo file to the specific Locale (for mine bn_BD.mo, for your case de_DE.mo)
I would suggest a few tips from here