1

In D7, we have two copies of the same Bootstrap Agency base theme modified to show on different URLs using ThemeKey.

This works, but whenever a new module is installed, the site crashes and we see the following in the Apache error log:

PHP Fatal error: Cannot redeclare bootstrap_agency_preprocess_page() (previously declared in /sites/all/themes/bootstrap_agency_minimal/template.php:13) in /sites/all/themes/bootstrap_agency/template.php on line 13

This is actually a very similar issue to this , I just couldn't comment on the above and Clive's answer wasn't all that clear to me. Is it better to merge the two functions or rename one of them - as the 2nd answer suggests? And what does merging entail?

  • Is there a bootstrap_agency_preprocess_page function inside of template.php in bootstrap_agency_minimal/template.php? – Kevin Jul 6 '16 at 18:28
1

Function names in template.php have to be prefixed with themename_function. At the same time, you cannot have a function declared twice.

bootstrap_agency_preprocess_page() should exist once in bootstrap_agency/template.php, and the other should be bootstrap_agency_minimal_preprocess_page() in bootstrap_agency_minimal/template.php.

If you do not need to do any override, and the one theme is a subtheme, you can simply omit it from template.php. Otherwise, you would need to copy the function code in and amend what you need to amend.

  • Thanks, Kevin! We've already tried this is an experiment and it worked. Good to know it's a proper solution and hot a hack that would break something elsewhere. – dubesor Jul 6 '16 at 18:39

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.