kongondo / MenuBuilder

Easily create navigation lists/menus using drag and drop
GNU General Public License v2.0
21 stars 9 forks source link

Fatal error: getLanguageValue() - only default language installed #25

Closed sanjom closed 8 years ago

sanjom commented 9 years ago

When a page is added to the menu (via ASM-select, I haven't tried autocomplete) this error is thrown:

Error: Call to a member function getLanguageValue() on a non-object (line 1750 of XXX\site\modules\ProcessMenuBuilder\ProcessMenuBuilder.module)

This error occurs under the following conditions:

The second point is where the error lies, I think. I have used the multilingual profile but because I will not need the additional languages for the moment, I have deleted all but the default. When I add another language, this error disappears.

My current workaround is to just comment out the if statement on that line and only use the code in the else statement.

PS: this issue is slightly different to Issue #22.

csaeum commented 8 years ago

Same Problem here

BitPoet commented 8 years ago

Same here as well. I guess a check for

&& method_exists(wire('pages')->get($itemID)->title, 'getLanguageValue')

should be included in the if condition in line 1750, as getLanguageValue seem to be unavailable if there's only one language configured. Alternatively, a

&& wire('languages')->count() > 1

should do the same.

csaeum commented 8 years ago

Thus, the line should look like in 1750 or?

if($language != null) $itemTitle = wire('pages')->get($itemID)->title->getLanguageValue($language) && method_exists(wire('pages')->get($itemID)->title, 'getLanguageValue'); //title of each PW page in this array

Sorry I'm no developer?

sanjom commented 8 years ago

Without looking at the code (I'm on my phone), I think BitPoet meant something like this:

if($language != null && method_exists(wire('pages')->get($itemID)->title, 'getLanguageValue')) $itemTitle = wire('pages')->get($itemID)->title->getLanguageValue($language); //title of each PW page in this array

BitPoet commented 8 years ago

Yes, thanks sanjom, that's what I meant. To be sure, I just tested it with LanguageSupport installed and uninstalled, and it worked perfectly both times.

sanjom commented 8 years ago

Sweet, how do we go about changing that in the official code?

BitPoet commented 8 years ago

I've submitted a pull request with the fix. Meanwhile, you can snatch the zip file from my development fork

kongondo commented 8 years ago

Accepted @BitPoet's PR (4d1b015493c54aa60aeda8c22295ac0a909e9afe). This is now fixed and available in version 011 (master and dev), thanks all.