Jump to content

Remove folder from site/templates?


DooM
 Share

Recommended Posts

Hello,

I'm working on something like "structure generator" for my own needs which is run after clean installation of PW to create basic structure, fields, install modules, remove unnecessities, etc.

I'm trying to remove site/templates/scripts and site/templates/styles folders, but I'm out of ideas already. When I try PHP's unlink function, it says that the path doesn't exists, which is obvious, because it will try to delete those folders under FileCompiler folder. This is probably because PW compilation process? I'm initializing this mine "structure generator" in ready.php.

Do any of you guys have any idea how to get rid of those folders? My styles and scripts folders are separated, so I don't need those two inside templates folder.

Thanks for every advice. ?

Link to comment
Share on other sites

Might also make sense to create your own site profile, set things up there beforehand, and then install that instead of one of the built-in site profiles. If your structure generator has a lot of flags and options you tweak on a case by case basis then that might not be feasible – but if not, what you're trying to solve here is exactly what site profiles are for ?

See https://modules.processwire.com/modules/process-export-profile/ for more details.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Zeka said:

Hi @DooM

Have you tried to use $files->rmdir ? 

https://processwire.com/api/ref/wire-file-tools/rmdir/

That doesn't seem to work. I've tried:

$files->rmdir($config->urls->templates . "styles", true);

@teppo, I tried to keep as few installation steps as possible, but yeah. Why not? I'll just add one extra step and use site profile instead. I see deleting those folders is problematic.

Thanks  a lot ?  

Edited by DooM
  • Like 1
Link to comment
Share on other sites

On 7/10/2019 at 7:01 AM, DooM said:

That doesn't seem to work. I've tried:


$files->rmdir($config->urls->templates . "styles", true);

 

Note that WireFileTools operations work on paths (on disk), not URLs – so $config->paths->templates would have a better chance of succeeding ?

One problem with file operations is that you need to give code a full write access to all your templates, etc. In my opinion that's not a good idea (considering security aspect of it), but of course this too depends on the case at hand. Personally I'd suggest going with site profiles, or using something else entirely (bash scripts or Composer or something – or perhaps Wireshell would have something that helps here?)

Link to comment
Share on other sites

On 7/10/2019 at 7:04 AM, teppo said:

Note that WireFileTools operations work on paths (on disk), not URLs – so $config->paths->templates would have a better chance of succeeding ?

One problem with file operations is that you need to give code a full write access to all your templates, etc. In my opinion that's not a good idea (considering security aspect of it), but of course this too depends on the case at hand. Personally I'd suggest going with site profiles, or using something else entirely (bash scripts or Composer or something – or perhaps wireshell would have something that helps here?)

Woow, that really did work! Thanks a lot! ? The Wireshell looks awesome. I'll check it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...