Jump to content

Where PS (1.6.0.8) return finale html to browser?


giedriusits

Recommended Posts





 

 


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 by giedriusits (see edit history)
Link to comment
Share on other sites

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

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 by giedriusits (see edit history)
Link to comment
Share on other sites

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 by catalin.pop (see edit history)
Link to comment
Share on other sites

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 by catalin.pop (see edit history)
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...