XF 1.5 How to add new URL variable template for http and https

Jawaad

Member
I have running my forum with http protocol.
After I change the url to https protocol, the problem is share facebook count, it doesn't count from http.
The suggestion from facebook is using old url.
So, how can I change the url share facebook from https to http?

I want to edit template: share_page:
PHP:
            <xen:if is="{$xenOptions.facebookLike}">
                <div class="facebookLike shareControl">
                    <xen:container var="$facebookSdk">1</xen:container>
                    <div class="fb-like" data-href="{$url}" data-width="400" data-layout="standard" data-action="{$xenOptions.facebookLikeAction}" data-show-faces="true" data-colorscheme="@fbColorScheme"></div>
                </div>
            </xen:if>

I'm thinking to replace {$url} from https:// to http://

How can I change this?
Thank You
 
In this context, {$url} is just the URL of the current page being viewed.

The share count should work over http or https. If the concern is that the share count is lower than it was before changing the URLs, then it's likely due to Facebook seeing your http URL and your https URL as distinct URLs; I would assume this is going to effectively reset the share counts everywhere to 0. If this is the case this is by (Facebook's) design and there's nothing you can do about that.
 
the URL of the current page being viewed
Yes, thats what I need.
The only change is https and http.
So, instead using new https, I want to use the http for facebook.
This is sample implement for wordpress:
PHP:
/**
 * Return HTTP version of a URL.
 *
 * @param string $url Original URL.
 *
 * @return string URL converted to HTTP.
 */
function get_http_url( $url ) {
    return preg_replace( '/https:/i', 'http:', $url );
}
 
/**
 * Output the HTTP version of the current post/page URL.
 *
 * @return string $url Current page/post URL converted to HTTP.
 */
function get_current_http_url() {
    // Get current URL
    $url = get_permalink();
 
    // Get HTTP version of URL
    $url = get_http_url( $url );
 
    return $url;
}
add_shortcode('http-url', 'get_current_http_url');
https://www.mightyminnow.com/2014/0...unts-and-comments-work-across-http-and-https/
 
Not sure it's ideal. Either way, there's possibly a way by editing the thread_view template.

Find:
Code:
<xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set>

Replace With:
Code:
<xen:set var="$url">http://{$requestPaths.host}{$requestPaths.requestUri}</xen:set>
 
Hello Chris, Thanks..
I just try following this https://xenforo.com/community/resources/how-to-create-your-own-helpers.332/

And I create helper to convert https to http, so I just call this in share_page template:
PHP:
data-href="{xen:helper nsi_gethttp, $url}"
the function:
PHP:
    public static function helperGethttp ($string) {
        $string = preg_replace( '/https:/i', 'http:', $string );
        return $string;
    }
And, it works, it display again the count. Also it works as well for gplus.
 
One more think template to edit for og:url in file open_graph_meta:
PHP:
    <xen:set var="$urlGethttp">{xen:helper nsi_gethttp, $url}</xen:set>
    <meta property="og:url" content="{xen:raw $urlGethttp}" />
 
Top Bottom