7

I am using protostar as a template for my 3.3.1 website. I have change the index.php in order to redesign the module positions and to add more of them.

I have just updated my website to Joomla 3.3.3 and... I have lost all my edits. (I have a backup so not the big deal).

So now I am wondering what is the best way to override the index.php in order to don't loose my edits each time I update. It seems that it's not possible to have my template index.php override in the template/protostar/html folder like the other overrides.

I found in a forum that I have to make a copy of the folder protostar and rename it to (let's say) protostarperso. Is that the best way to do it?

Thanks a lot!

2 Answers 2

9

Yes, the best way is to copy the desired template by Joomla admin. Go to Extensions > Template Manager > Templates and click on desired template.

Template Manager::Templates

Then click on Copy Template and enter the new name.

enter image description here

Then make it default and work on the index.php file.

Side notes:

The reason why your changes got overridden is because sicne the initial release of the Protostar template with Joomla 3.0.0, some fixes have been made, and now that every update package contains all updates since 3.0.0, the Protostar template will always be installed from scratch.

Just remember that what you did is a prime example of why editing core files is a bad idea. I know some people to have heavily modify core files and not had backups and therefore getting rather annoyed that they cannot get their changes back.

4
  • 2
    Ahh just removed my answer. Apparently duplicating the style is not he same as copying the template ad will not protected against overrides. Added some side notes from my answer to yours just as an extra
    – Lodder
    Commented Aug 24, 2014 at 8:32
  • Thanks so much Fari for the print-screen. I didn't know about this backend feaures. Know, thanks to you, I am protected from loosing my edits!
    – MagTun
    Commented Aug 24, 2014 at 8:43
  • @Lodder, thanks for the side notes, I will be more carefull with overrides now (I do them sometimes, but not all the times)
    – MagTun
    Commented Aug 24, 2014 at 8:44
  • @Lodder I have just thought that if I copy the protostar template then I will loose all the fixes that are made in Protostar in the new Joomla version. But I guess there is not other way than either edit core file/make a backup/update/edit core files with previous changes (a bit of hassles, but keep the fixes that are made) OR duplicate the template (simple but I loose the fixes). Maybe there is a third way of doing it?
    – MagTun
    Commented Aug 24, 2014 at 9:30
2

It is also possible to use the Linux/UNIX diff and patch commands to store the changes that you have made to the template core files so that you may easily reapply them to the template when it is updated.

To create a patch file that contains all the changes you have made to the template core files:

  1. Install the latest version of the template (clean install).
  2. Use the Copy Template procedure to copy the template to a new directory.
  3. Make edits to the template core files in the new directory.
  4. Make sure that you are in the joomla_root/template directory.
  5. diff -rupN template_original/ template_new/ > template.patch

To apply the patch file to the recently updated template:

  1. Update the template with the latest version.
  2. Use the Copy Template procedure to copy the template to a new directory.
  3. Make sure that you are in the joomla_root/template/template_new directory.
  4. patch -p1 < template.patch

I hope that this helps.

The Ten Minute Guide to diff and patch

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