1

Yesterday, I posted a proposal for clarifying the procedure for updating core. But now I find that I messed up in doing my update and I'm not sure how to do it right the next time.

I have a set of Views templates under the Bartik theme. They are in the folder: <Drupal root>\themes\bartik\templates\views In the update procedure, this folder is deleted along with the rest of the old core.

I was able to easily restore the views folder from the backup, but I'd like to not have to do that in the future.

Generally, it seems like a bad idea to put custom content in a core folder, but it seems that Views needs the template folder to be under the theme it applies to.

Is there a way to put that views folder under the sites folder or somewhere else outside of the core structure so it won't get deleted when I do an update?

Thanks for your help.

5

Editing files in themes\bartik\templates\views is hacking core. One ought not to. You should create a subtheme of Bartik and make your changes there. Then an upgrade will not wipe out your changes.

Clear exceptions to the rule for editing core files are robots.txt, .htaccess and web.config.

  • That folder was created by me as a subfolder of the core "bartik/templates" folder in order to keep my Views templates separate from the core files. As far as I understand, Views requires me to keep templates in the folder of the theme it is working with. I'm not making any changes to Bartik, so it seems excessive to create a whole subtheme just to be able to use Views with a theme. Am I wrong about any of that? – NewSites May 9 '15 at 14:09
  • You need to create complete subtheme at sites/[all|default|sitename]/themes/[subtheme_name]. The minimum requirement for a theme is the .info file, so you will likely start with that and your template file, which I would put in themes/[subtheme_name]/templates/views/* Adding a few directories and one additional file isn't a big deal. – fullerja May 9 '15 at 16:58
  • @NewSites follow this tutorial youtube.com/watch?v=1Cfc11_sb5M – No Sssweat May 9 '15 at 18:33
  • @fullerja - I've done some more research and found out that you're right that I should be using a subtheme. Thank you. – NewSites May 10 '15 at 6:43
0

There is actually quite some information available about updating – at least over at drupal.org.

Here is the page 'Update Drupal Core' in the Community Documentation at drupal.org and here is a neighbouring page about 'Installing modules and themes' that may clear some aspects of how and where to put modules and themes etc. But you probably came across these pages.

However – in short: first thing I learnt is to always put your custom themes, modules etc. in sites/all/… or sites/default/… since that's a folder that is not deleted – or at least should not be deleted while updating core.

[EDIT] Sometimes you may encounter problems finding the correct name for your tpl file – then drupal won't load it and you'll have the impression that 'it just does'nt worl'. Views has astally a handy feature listing the suggested tpl names for a specific view – it's just a bit hidden: Advanced > Theme: Information.

For further info on naming these pages could also be useful: 'Views template files' and 'Drupal 7 Template (Theme Hook) Suggestions'.

ps: rule of thumb: don't touch the core! (That's why it's called 'core' -- and this applies also to 'core modules' )

  • The update page you link to is included in my proposal (linked in my question) for changes to the updating instructions. As far as I understand, Views requires me to keep templates in the folder of the theme it is working with. I was not able to get Views to recognize templates put anywhere else. So unless you're telling me not to use Views with Bartik, it seems that I have no choice but to put Views templates in Bartik's folder. Am I wrong about that? (At least I keep them in a separate subfolder to distinguish my templates from Drupal's.) – NewSites May 9 '15 at 14:19
  • afaik all template files can go into sites/all no matter if it's a views template or any other. There may be however a naming problem? What is the name of the view / name of the template file…? – tillinberlin May 9 '15 at 14:32
  • I tried putting my first template within "sites" and Views didn't find it. Researching the problem, I found a post that said the templates have to be in the folder of the theme being used. So I put it there and that's when Views found it. Have you used Views with a core theme and put the templates under "sites"? If you did, please say what path you used and I'll try it. For your other question, I have three views under Bartik. One of the templates is "views-view-table--z-links-gen--block-1.tpl.php". These names are generated by Views and I have no control of them. – NewSites May 9 '15 at 15:04
  • I've submitted an issue (drupal.org/node/2486123) to Views about this. It is excessive to require a subtheme just to be able to use a module. Views is requiring a violation of Drupal best practices in order to use it with a core theme. – NewSites May 9 '15 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.