giedriusits Posted September 25, 2017 Share Posted September 25, 2017 Hello, Where PS (1.6.0.8) return finale html to browser? I need to do some str_replace() if its possible. Thanks. Link to comment Share on other sites More sharing options...
catalin.pop Posted September 25, 2017 Share Posted September 25, 2017 What do you mean by "finale html"? if you want to change some data that is rendered in html you either change it from Controllers(prestashop_files/controllers) or from template(prestashop_files/themes/your_theme) Link to comment Share on other sites More sharing options...
giedriusits Posted September 25, 2017 Author Share Posted September 25, 2017 (edited) I need, temporary and fast solution, to change "http:" to "". Its written and hardcoded in many places: content, DB, modules, templates... So i just want get all rendered page HTML and use this PHP function: str_replace('http://', '//', $html) Iknow, that its not a good way.. Edited September 25, 2017 by giedriusits (see edit history) Link to comment Share on other sites More sharing options...
catalin.pop Posted September 25, 2017 Share Posted September 25, 2017 In Tools.php from prestashop161/classes you can change this method getShopProtocol() public static function getShopProtocol() { $protocol = (Configuration::get('PS_SSL_ENABLED') || (!empty($_SERVER['HTTPS']) && Tools::strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; return $protocol; } to public static function getShopProtocol() { return "//"; } I wouldn't recommend it, but it's the fastest method Link to comment Share on other sites More sharing options...
giedriusits Posted September 25, 2017 Author Share Posted September 25, 2017 (edited) catalin.pop, its not working for me (i try overide, clear all cash)... in my page, on browser i get images, maps... links like that: <img src="http://goo.gl/GST13y" width="302" height="282" /> http://map.... so i need remove http: or change to https: i get Mixed Content Warnings with HTTPS Edited September 25, 2017 by giedriusits (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted September 25, 2017 Share Posted September 25, 2017 so what exactly are you trying to solve (explain in human terms). You want to fix mixed content warnings? Or you want to remove all http: ? Link to comment Share on other sites More sharing options...
giedriusits Posted September 25, 2017 Author Share Posted September 25, 2017 (edited) Thanks for helping i want fix mixed content warnings. On my page code are many links with http : ..., and many content writen with http : links, like images... i cant find them all and fix. Edited September 25, 2017 by giedriusits (see edit history) Link to comment Share on other sites More sharing options...
catalin.pop Posted September 25, 2017 Share Posted September 25, 2017 (edited) OK. The method I provided changes the protocol for internal links. It doesn't help you with links to other websites. The clean way to do that is to take every template file and change it manually. The more messy and ugly way is to embed a javascript file that will automatically strip http from all urls. For example for images function stripHttp(string:String, stripWWW:Boolean = false):String { var s:String = string; var regexp:RegExp = new RegExp(!stripWWW ? "https*:\/\/" : "https*:\/\/(www\.)*", "ig"); return s.replace(regexp, ""); } $(window).ready(function(){ $('img').each(function(){ var img = $(this); var srcOld = img.attr('src'); var srcNew = stripHttp(srcOld); img.attr('src', srcNew); // Updating src here }); }); You can change the stripHttp method if you want a different result. In that example it transforms http://example.com into example.com Edited September 25, 2017 by catalin.pop (see edit history) Link to comment Share on other sites More sharing options...
giedriusits Posted September 25, 2017 Author Share Posted September 25, 2017 so, its not exist some single place, where prestashop render all HTML and throw it to browser? Like echo $html Link to comment Share on other sites More sharing options...
catalin.pop Posted September 25, 2017 Share Posted September 25, 2017 (edited) Templates are rendered by Smarty Best way is to look in Controller.php (prestashop/classes/controller) at smartyOutputContent /** * Renders controller templates and generates page content * * @param array|string $content Template file(s) to be rendered * @throws Exception * @throws SmartyException */ protected function smartyOutputContent($content) { $this->context->cookie->write(); $html = ''; . . . echo $html; // I think this is the html var you're looking for } Edited September 25, 2017 by catalin.pop (see edit history) Link to comment Share on other sites More sharing options...
giedriusits Posted September 25, 2017 Author Share Posted September 25, 2017 Bingo! Link to comment Share on other sites More sharing options...
bellini13 Posted September 25, 2017 Share Posted September 25, 2017 this would seem like a bandaid, you really should be fixing the root of the issue, which is... why do you have mixed content warnings to begin with. I assume you have a valid SSL certificate installed on the server, and that you have also "Enabled SSL" and "Force SSL on all pages" options in Prestashop back office? If so, and you have mixed content warnings, then it means you have a theme/modules installed that are not properly coded. Link to comment Share on other sites More sharing options...
giedriusits Posted September 26, 2017 Author Share Posted September 26, 2017 Its my clients old shop and i making him new one. The old one is really messy, so i dont want spend time to find all problems. thanks for help. 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