Jump to content

Fatal Error: Templates


Go to solution Solved by Alexandru,

Recommended Posts

Hi.
I've noticed since 4.7.6 or something like this, when creating/uploading a new theme that has a custom tab in it, it will throw this error.

I have checked in .../.../.../system/Theme/Theme.php on line 1783 the code itself, and I saw it was from the custom tabs, that how I came to this conclusion.

This error seems to be on multiple installations to which I have access. I had designers mode enabled to create some custom tabs ( fields ) for my template, after saving. On the front-end page, it showed me this, I tried on 3 installations, 1 of them is on 4.7.8 and the other 2 are on 4.7.9.  I checked my custom php code over 10 times and there are no mistakes with the code itself.
Today was the day to finish the template for a client, I guess now I need to take a break until fixed. 😔😑😪


Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /home/community name/public_html/directory/system/Theme/Theme.php(885) : eval()'d code on line 1783

 

Edited by drawncodes
Link to comment
Share on other sites

Your issue isn't on line 1783, but 885, so this is not related to your custom tabs.
But it is on line 1783 of the compiled template code, which is sort of impossible to debug.

Somewhere in the templates there's unsupported ternary usage, or it's still using an old template from the default theme.

Not an easy thing to debug, but what you're looking for is something like this

{{$var = $foo ? 1 : $bar ? 2 : 3;}}

Which should be

{{$var = $foo ? 1 : ( $bar ? 2 : 3 );}}

 

Edited by Martin A.
Link to comment
Share on other sites

25 minutes ago, Martin A. said:

Your issue isn't on line 1783, but 885, so this is not related to your custom tabs.
But it is on line 1783 of the compiled template code, which is sort of impossible to debug.

Somewhere in the templates there's unsupported ternary usage, or it's still using an old template from the default theme.

Not an easy thing to debug, but what you're looking for is something like this

{{$var = $foo ? 1 : $bar ? 2 : 3;}}

Which should be

{{$var = $foo ? 1 : ( $bar ? 2 : 3 );}}

 

I'm afraid that's happening even on the default template. It's not from my custom theme cuz I tried it on the default theme and also throws me that error.

Link to comment
Share on other sites

Just now, Adriano Faria said:

This is related to PHP version. Search for Unparenthesized and you'll see tons of topics.

How could it be? When I'm on PHP 8.0.0 and the latest version of invision? Am I missing something here?

So that means, It's not my doing. That means they have to fix it, right?

 

Link to comment
Share on other sites

Let's just say for a moment is my doing, and I'm going to recheck again my code. Right now one of my installations is gone completely cuz of this and I have no time to look at it why this happened. I will restore the backup from yesterday for it.

I know for sure this is a problem from the update, cuz today I was trying to upload/create a new default theme and it threw me that error even with a new theme created ( The default one that comes with installation ). Which seems weird enough. I made this topic hoping that the DEV Team will look into this.

Link to comment
Share on other sites

This could be an issue with your template itself or potentially with one of your 3rd party resources if it has its own template issues.  I would suggest going back to as close to a stock board as possible (including theme) and turning things back one at a time until you find your problem.  

Link to comment
Share on other sites

Just now, Randy Calvert said:

This could be an issue with your template itself or potentially with one of your 3rd party resources if it has its own template issues.  I would suggest going back to as close to a stock board as possible (including theme) and turning things back one at a time until you find your problem.  

Sure thing.
At first, I also thought this might be from a 3rd party we have installed. But I tried it on a brand new installation so to say and I have no 3rd plugins/applications and still threw me that error. Anyhow, I will look again over it and I will come here with an update if I find a solution to it. I will be posting the solution to it here / or what caused this to happen.

Link to comment
Share on other sites

<?php
return new \IPS\Helpers\Form\Select("core_theme_setting_title_{$row['sc_id']}", $value == '*' ? "*" : explode(',', $value) , false, array(
    'options' => \IPS\Member\Group::groups(true, true) ,
    'parse' => 'normal',
    'multiple' => true,
    'unlimited' => '*',
    'unlimitedLang' => 'all_groups'
) , NULL, NULL, NULL, 'theme_setting_' . $row['sc_key']);
<?php
return new \IPS\Helpers\Form\Select("core_theme_setting_title_{$row['sc_id']}", $value ? explode(',', $value) : array() , false, array(
    'options' => array(
        'register' => 'Register Page',
        'login' => 'Login Page',
        'profiles' => 'User Profile Page',
        'messages' => 'Messages Page',
        'search' => 'Search Page',
        'activity' => 'Activity Page',
        'leaderboard' => 'Leaderboard',
        'staff' => 'Staff Page',
        'forumsIndex' => 'Forums Index',
        'categories' => 'Forums Categories',
        'forumsTopics' => 'Forums Topics',
        'clubsindex' => 'Clubs - Index',
        'clubsview' => 'Clubs - View clubs',
        'pages' => 'Pages',
        'gallery' => 'Gallery',
        'blogs' => 'Blogs',
        'downloads' => 'Downloads'
    ) ,
    'parse' => 'normal',
    'multiple' => true
) , NULL, NULL, NULL, 'theme_setting_' . $row['sc_key']);
<?php
return new \IPS\Helpers\Form\Text("core_theme_setting_title_{$row['sc_id']}", $value, false, array(
    'autocomplete' => array(
        'source' => array(
            "Slide 1",
            "Slide 2",
            "Slide 3",
            "Slide 4"
        ) ,
        'freeChoice' => false,
        'forceLower' => false,
        'unique' => true
    )
) , NULL, NULL, NULL, 'theme_setting_' . $row['sc_key']);

This is the latest code I used in custom tabs when designer mode enabled.

I think it's from this 

"*" : explode(',', $value)

It must be.. 

("*" : explode(',', $value))

Hope I m not wrong 😑

Edited by drawncodes
Link to comment
Share on other sites

  • Solution

Oops 😛
Well, the problem is fixed, my bad.
I uploaded again the template I had a problem with and enabled the designer mode again I tried "Advanced: Sync from file system" and it seems to work now. 

Why didn't I think of this before? 😞

Anyway, thank you everybody for your time and help 😛

Edited by drawncodes
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...