FOSUserBundle not overriding twig template in specific cases - symfony

I am using FOSUserBundle in some Symfony2 Projects.
To override the login page, I normally create a Twig file like this: /app/Resources/FOSUserBundle/views/security/login.html.twig.
In the past projects I created, this worked normally and did override the login page.
Recently, I have been working on a new Symfony project with a teammate. Overriding the login page worked in my environment but NOT in his environment. We tried uploading the project to a test server where it also didn't override the login page (It used to override it for other projects we tested).
We are using Symfony 2.7 with Linux Distros for all the environments. In my case, I use Ubuntu Server. My teammate runs Ubuntu Mate and the test server runs Ubuntu.
We checked folder permissions and ownerships and everything is ok.
Everything in the project works except this little twig override for the FOSUserBundle login page.
We already tried php clear:cache and manually deleting the cache folder.
We also tried this solution: What is the issue with not overriding templates in symfony2.6 and FOSUserBundle 1.3, where the answer suggests that the problem is the way PHP caches the file stats. This also didnt' work.
Any suggestions or maybe some PHP configs that we could try?
Thanks in advance,

It may be a problem with a case sensitivity.
Change it to /app/Resources/FOSUserBundle/views/Security/login.html.twig (lower case s -> upper case S). And then check by ls -l (also check your version control if relevant).

Related

Django project does not work after being transferred from Windows to Mac

I'm using Django 3.1.7 on a MacBook Pro after transferring the Django project off of a Windows 10 machine. However, upon re-setting up the database and superuser and running the command pipenv sync to install all necessary modules, the server does run; but it doesn't serve any of my URLs or the CSS styles for the Admin page. I can reach the admin page at '/admin' but no other page that I've set up will display. All it gives me is my custom 404 page whenever I try to serve a page. Is there any way to fix this? Is something wrong? Where are the Admin CSS files?
python manage.py runserver --insecure
Use the --insecure option to force serving of static files with the staticfiles app even if the DEBUG setting is False.
djangoproject
I think we'd need more information... maybe the files itself.
There could be tons of things that could go wrong. Is your settings.py still pointing to the correct file paths? In views.py, did you make sure you are setting the html files in the same path? Are the html files in the right folder? Are all the Django and module versions the same? There's too much to name.
I have the same problem.
By what you are describing it happens because your file path uses either / or
One machine uses forward slash and the other backwards slash
I dont know to so use a method that work on both

Silverstripe install admin js errors

For some reason my admin screen just hangs with some javascript errors. I have it installed on xampp on windows 7 ultimate 64bit. What could be causing this? Ill post a screenshot of the errors any help would be nice! p.s. This is my first time installing silverstripe ever so be nice. :)
This sort of things usually occurs when combined asset files cannot be created. Make sure the web server user has write access to the assets/ and assets/_combinedfiles folders, then go to your-site.com/admin/pages?flush=1.
Alternatively, since this is a local install, run in dev mode. There are instructions in the documentation on how to set this.
As indicated by #simon_w, this issue occurs due to the folder permissions:
In your local environment, in addition to the way via yml config, you can just put the following in _config.php inside mysite folder.
Director::set_environment_type("dev");
In dev mode, the installation doesnt need to write to assets/_combinedfiles. However, you had better have write permission for assets folder anyway.
So, just increase permissions for assets and directories under it. Uploaded files are also stored there, if not sufficient permission, you can't upload files from the admin panel. Other functionalists may also be affected.

how to install securefiles in silverstripe 3

i'm trying to install the securefiles module https://github.com/hamishcampbell/silverstripe-securefiles on my silverstripe 3 installation.
After renaming, uploading and dev/build
i get two checkboxes in security>groups>groupname>permissions named Access to Secured Files and Manage File Security Settings.
But that's all.
and when i want to access the files section in silverstripe i get a server error.
Can someone tell me what i need to modify that secure files is working?
That extension seems to be only compatible with SS2.x so for SS3 you might need to find another extension, update it for 3.x (http://doc.silverstripe.org/framework/en/trunk/changelogs/3.1.0) or try a custom approach like Silverstripe - google picks links on members only page

Symfony cannot find template on prod server

Should be simple enough. Everything works in my local environment, but not on my prod server (neither prod nor dev environment). I get an error that the FOS template cannot be found:
Unable to find template "FOSUserBundle::layout.html.twig".
My code is simple:
{% extends "FOSUserBundle::layout.html.twig" %}
I'm going from my local Windows machine to a Linux box. I've read case sensitivity might be the culprit, but it doesn't seem like it.
The FOS bundle is in the normal place: vendor/friendsofsymfony/user-bundle/FOS/UserBundle.
I'm having trouble diagnosing - any ideas? Did things get screwed up when I FTPd? Permissions issues? What are the common gotchas? I'm desparate!
Update: A clue. I ran assetic:dump and got
[RuntimeException]
".../app/Resources/FOSUserBundle/views/layout.html.twig" resource is hidden by a
resource from the "*******Bundle" derived bundle. Create a
".../app/Resources/*******Bundle/views/layout.html.twig" file to override the bundle
resource.
This question seems relevant.
Another update: I was using getParent() in my own bundle to override the templates. I switched to the first method in the docs but now the templates in app/resources simply aren't having an effect. It's going straight to the default form template with a white background.
Any ideas?
It was a upper/lower case/namespacing thing. I thought my local files were in sync with remotes but they were not.
Just check your whole directory & all namespaces in the FOS bundle!
I also encountered the problem and "solved" it by renaming my layout.html.twig inside my bundle's Resources/views folder to bundle-layout.html.twig and adapting my templates accordingly.
I resolved the resource is hidden by a resource error by moving the template in the good bundle extension.
Specifically from app/Resources/FOSUSerBundle/views/ChangePassword
to src/Application/Sonata/UserBundle/Resources/views/ChangePassword
I confounded FOSUser & SonataUser.

System.Web.Optimization bundles are empty when running in a virtual directory

I'm having problems when deploying my application to a server using a virtual directory in IIS.
I have configured the same files to run under the default website in a virtual directly and also in a new website root running on port 81. Both configurations use their own identical app pools. While the site on port 81 works fine the site running in a virtual directory doesn't load the bundles.
In the page I see links with missing versions in the URL, such as:
<link href="/MyVirtualDir/Content/css/site?v=" rel="stylesheet">
The URL returns a 200 status from the server, but the content is completely empty.
I have looked on SO at questions like this which references this bug ticket but my understanding is that this is when the files being included in the bundle are 'virtual' or not under the physical folder root. Which is not true in my case.
Cheers for any help you can give me. I can't believe that this configuration wouldn't be supported so I must be doing something wrong somewhere!
Update:
I think a ticket describing my problem has been raised on the web optimisations codeplex site here http://aspnetoptimization.codeplex.com/workitem/55 Not that this gets me any further though :(
After comparing with a new project I tracked down the problem:
I was using T4MVC (trying to be clever and not use 'magic strings' in my code). So I was using a link such as
bundles.Add(new ScriptBundle("~/Scripts/all")
.Include("~"+Links.Scripts.Library.jqueryPlugin.jquery_ui_js), ...));
When this runs under a virtual directory it will resolve with the virtual directory name in the path, so it can't find the files.
I hope this helps someone else who runs into the same problem. Also, it looks like T4MVC are looking to improve the use of magic strings in bundles in future releases. See here for a discussion

Resources