Closed (fixed)
Project:
Fusion
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Dec 2010 at 14:54 UTC
Updated:
24 Dec 2010 at 05:40 UTC
Hello,
I try to use the function preprocess_pag in template.php but I get a fatal error:
function fusion_core_preprocess_page(&$variables) {
if ($variables['node']->type == "house") {
$variables['template_files'][] = 'page-node-house';
}
} (-->line 532)
Fatal error: Cannot redeclare fusion_core_preprocess_page() (previously declared in /www/sites/all/themes/fusion/fusion_core/template.php:29) in www/sites/all/themes/fusion/fusion_core/template.php on line 532
Any idea why I get this error? Thanks :)
Comments
Comment #1
jeremycaldwell commentedAre you defining "function fusion_core_preprocess_page(&$variables) {" yourself or modifying the call to that function that already exists in the Fusion Core template.php file? It sounds like you are adding it rather than modifying the existing page preprocess.
Do a search in your template.php and see how many times "function fusion_core_preprocess_page(&$variables) {" appears. If it appears more than once then you need to merge your changes with the other.
Comment #2
jeremycaldwell commentedOne more thing, if you are creating sub-theme of Fusion Core you can define the "function fusion_core_preprocess_page(&$variables) {" as something different and in your sub-theme's template.php.
Just change "function fusion_core_preprocess_page(&$variables) {" to "function YOURTHEME_preprocess_page(&$variables) {" where "YOURTHEME" is the name of your theme.
Comment #3
junro commentedAre you defining "function fusion_core_preprocess_page(&$variables) {" yourself
yes, so I had it twice. I'm going to change that.
if you are creating sub-theme of Fusion Core
I'm using Acquia Marina theme.
The problem is there is no template.php by default in this theme.
So I created one, and added aquia_marina_preprocess_page function but it doesn't work.
I think the template.php is not loaded, not take into account.
I was thinking I could use the template.php of core fusion, but apparently it's not the good decision.
Comment #4
jeremycaldwell commentedYou're on the right track with the template.php. Since the Acquia Marina theme did not come with a template.php you needed to create one. This works along with the one provided by Fusion Core and the idea is you want to include all your custom changes and that sort of thing outside of Fusion Core. So no touching Fusion Core :)
Now that you have the template.php created and the function, try going to your Performance page and clearing the site cache. That will reload the theme files and pick up the template.php and the function within it.
Comment #5
junro commentedThanks for your help, but it still doesn't work.
I add this im my acquia marina template file:
For testing, my travels.tpl.php is empty in order to have a blank page, and to know if it's working...
The only way I can use template files for now is adding code in my page.tpl.php:
but in fact, I would like to have a template for the edit page of the node type, and in all post I read, the code should be in the template.tpl.php file.
I was hopping to use the code below in page.tpl.php to custom the edit page but it doesn't work:
Comment #6
junro commentedSorry, but this code in page.tpl.php works after running cron, it's weird, doesn't it? Flush all caches didn't do anything...
Comment #7
jeremycaldwell commentedInteresting that it works after running CRON but didn't work after clearing cache.. oh well, glad you got it working! And thanks for posting up the code too.