mds Posted December 28, 2016 Share Posted December 28, 2016 I'm getting this error. Error: Uncaught Error: Call to a member function getLanguageValue() on null in /Applications/MAMP/htdocs/site/templates/_head.php:36 Stack trace: #0 /Applications/MAMP/htdocs/site/templates/home.php(1): include_once() #1 /Applications/MAMP/htdocs/wire/core/TemplateFile.php(268): require('/Applications/M...') #2 /Applications/MAMP/htdocs/wire/core/Wire.php(374): ProcessWire\TemplateFile->___render() #3 /Applications/MAMP/htdocs/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___render', Array) #4 /Applications/MAMP/htdocs/wire/core/Wire.php(402): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #5 /Applications/MAMP/htdocs/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array) #6 [internal function]: ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #7 /Applications/MAMP/htdocs/wire/core/Wire.php(376): call_user_func_array(Array, Array) #8 /Applications/MAMP/htdocs/wi (line 36 of /Applications/MAMP/htdocs/site/templates/_head.php) This error message was shown because: you are logged in as a Superuser. Error has been logged. I got the error after installing the module ProcessWireUpgrade and upgrading ProcessWire Core Dev to 3.0.46. This is what is in the _head.php file (standard form multi-language setup. The line with the error starts with $hreflang <?php // handle output of 'hreflang' link tags for multi-language // this is good to do for SEO in helping search engines understand // what languages your site is presented in foreach($languages as $language) { // if this page is not viewable in the language, skip it if(!$page->viewable($language)) continue; // get the http URL for this page in the given language $url = $page->localHttpUrl($language); // hreflang code for language uses language name from homepage $hreflang = $homepage->getLanguageValue($language, 'name'); // output the <link> tag: note that this assumes your language names are the same as required by hreflang. echo "\n\t<link rel='alternate' hreflang='$hreflang' href='$url' />"; } ?> How do I begin to fix this error? Link to comment Share on other sites More sharing options...
adrian Posted December 28, 2016 Share Posted December 28, 2016 Looking at the languages site profile, there is no _head.php file: https://github.com/processwire/processwire/tree/dev/site-languages/templates Maybe you are combining files from different profiles? Regardless, the key thing is that $homepage is null so you need to define it somewhere before the line that calls the getLanguageValue on it. Currently the languages site profile does this in the _init.php file: https://github.com/processwire/processwire/blob/e12095e622555fe79cd792dea1ed7d671e37d9d4/site-languages/templates/_init.php#L26 1 Link to comment Share on other sites More sharing options...
mds Posted December 28, 2016 Author Share Posted December 28, 2016 In a previous version, the _init.php was automatically added unless otherwise selected in template - files tab. That's what caused my troubles. Thanks for directing me to the solution! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now