servetsarap Posted September 11, 2016 Share Posted September 11, 2016 (edited) Hello, I've a override file to make search page's title as query. But I want to make first letter uppercase. When I add ucfirst, the page gives http500 error. Where do I need to add ucfirst()? Here is the code: <?phpclass Meta extends MetaCore{ public static function getMetaByPage($page, $id_lang) { $search_translations = array(1 => "Search results for query", 2 => "Recherche résultats pour requête"); $tag_translations = array(1 => "Search results for tag", 2 => "Recherche résultats pour tag"); if ($page == 'search' && Tools::getValue('search_query')) return array('title' => Tools::getValue('search_query'), 'description' => (isset($search_translations[$id_lang]) ? $search_translations[$id_lang] : $search_translations[1])." '".Tools::getValue('search_query')."'"); elseif ($page == 'search' && Tools::getValue('tag')) return array('title' => Tools::getValue('tag'), 'description' => (isset($tag_translations[$id_lang]) ? $tag_translations[$id_lang] : $tag_translations[1])." '".Tools::getValue('tag')."'"); else return parent::getMetaByPage($page, $id_lang); }} Edited September 12, 2016 by servetsarap (see edit history) Link to comment Share on other sites More sharing options...
modprestashop Posted September 11, 2016 Share Posted September 11, 2016 (edited) When you are working with PrestaShop, you should use PrestaShop specific function. So use Tools::ucfirst() and i can't find ucfirst() function in your code. Try following code: class Meta extends MetaCore { public static function getMetaByPage($page, $id_lang) { $search_translations = array(1 => "Search results for query", 2 => "Recherche résultats pour requête"); $tag_translations = array(1 => "Search results for tag", 2 => "Recherche résultats pour tag"); if ($page == 'search' && Tools::getValue('search_query')) return array('title' => Tools::ucfirst(Tools::getValue('search_query')), 'description' => (isset($search_translations[$id_lang]) ? $search_translations[$id_lang] : $search_translations[1]). " '".Tools::getValue('search_query')."'"); elseif ($page == 'search' && Tools::getValue('tag')) return array('title' => Tools::ucfirst(Tools::getValue('tag')), 'description' => (isset($tag_translations[$id_lang]) ? $tag_translations[$id_lang] : $tag_translations[1]). " '".Tools::getValue('tag')."'"); else return parent::getMetaByPage($page, $id_lang); } } Edited September 11, 2016 by modprestashop (see edit history) 3 Link to comment Share on other sites More sharing options...
servetsarap Posted September 12, 2016 Author Share Posted September 12, 2016 (edited) It works. Thank you for your help I've spent my 2 days with this i'm totally newbie with codes. It solved. Edited September 12, 2016 by servetsarap (see edit history) 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