Domanda

I am building an application that allows a user to browse html templates. The html template will be displayed in a preview area (source code will be obfuscated), and although the template will contain inline CSS/JS, there will also be the odd linked image asset.

For this reason, I thought it might be best for me to just store them as a library of folders, and retrieve the flat file from my server for display, as opposed to storing the HTML in the database and having to organise the external assets too.

My question is: Where in the CakePHP directory structure, is the best home for these files? I'd rather keep them above the webroot, and I'm thinking View.

Any ideas? Thanks.

È stato utile?

Soluzione

I would suggest that you keep all the out-of-cakephp-framework related files, stored under the webroot.

My suggestion is the following directory structure for saving the html template as well as the css and js related files.

/webroot/files/templates/<template-project-name>/<the-actual-file>.html

Any external css, would then be under /webroot/css/templates/<template-project-name>/<the-actual-css>.css

And the JS libraries would be under /webroot/js/templates/<template-project-name>/<the-actual-js>.js

Use a seperate layout file (call it preview_layout.ctp) which simply renders the template file as it is.

Hope it helps

Altri suggerimenti

Why do you want to store them above the webroot, when they are publicly-viewable assets? My gut feeling is that they really belong in the webroot or in the database. I would pick one or the other.

If you must store them above the webroot, I guess the best thing might be to store them as elements.

app/View/Elements/your_templates/

And that way, you can load it into the preview area of your View using:

echo $this->element('your_templates/template');

Edit:

Honestly, the suggestion of elements is not what I would recommend, I'm just trying to offer you different suggestions. It would be terribly bad practice and I think it will be more messy and problematic than it's worth.

As for the image files, put them in the webroot, regardless of where you choose to store the HTML templates. You can't stop people downloading the images once they are viewing them in their browser anyway.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top