Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1233925

    Hi, I’m hoping you can help, please.

    There is a recurring issue with your theme that causes the URL to be rewritten when a # link is clicked in the page.

    This happens when the page is scrolled from the top and a link is clicked.

    You seem to have assumed that the only # href elements in a page would be related to your page builder and that no other plugins or pages would include these. This is an incorrect assumption which is causing issues for our site’s functionality.

    Could you please outline how to remove this ‘feature’ permanently across our site?

    Thanks

    • This topic was modified 4 years, 3 months ago by mbisogno.
    #1233958

    Further to the above, we are currently having to edit the main theme as follows:

    Comment out the following in this file/line

    js/avia.js 773

    if(window.history.replaceState)
    window.history.replaceState(“”, “”, newHash);

    We use a child theme but cannot find a way to overwrite this therein, so have to re-edit the main theme each time an update is installed.

    #1234466

    Hi,

    That is how anchor links work in html, it’s not really something theme specific. If I’ve misunderstood your then please try to explain a bit further and post a link to where we can see the problem in question.

    Best regards,
    Rikard

    #1236746

    Hi Rikard

    This
    https://www.geegeez.co.uk/racecards/#id=372422&display=full-results
    is an example of a link in our world. We use the # as a legitimate part of the url but, because Avia’s page builder seems to claim exclusive url rights to # it causes strange behaviour.

    Our workaround is above, but we have to do this every time the theme updates.

    We’d very much like to remove this once and for all. Do you have any suggestions?

    Hopefully that is clearer, though I’m not convinced it is!

    Matt

    #1238119

    This is the problematic code:

    // make sure it’s the same location
    if(oldLocation+newHash==newLocation || originHash)
    {
    if(cur_offset != target) // if current pos and target are the same dont scroll
    {
    if(!(cur_offset == 0 && target <= 0 )) // if we are at the top dont try to scroll to top or above
    {
    the_win.trigger(‘avia_smooth_scroll_start’);

    // animate to target and set the hash to the window.location after the animation
    $(‘html:not(:animated),body:not(:animated)’).animate({ scrollTop: target }, duration, easing, function() {

    // add new hash to the browser location
    //window.location.href=newLocation;
    //if(window.history.replaceState)
    //window.history.replaceState(“”, “”, newHash);
    });
    }
    }

    As you can see, we comment it out; but it keeps recurring every time there’s a theme upgrade.
    How can we move this to the child theme such that it doesn’t continually cause us issues?

    #1238315

    Hi,
    Sorry for the late reply, to load your edited /avia.js file via the child theme, first ensure that your file is at: /enfold-child/js/avia.js by creating a folder called “js” in your child theme directory.
    Then add this code to the end of your child theme functions.php file in Appearance > Editor:

    //Load child theme avia.js
    function wp_change_aviajs() {
    	wp_dequeue_script( 'avia-default', get_template_directory().'/js/avia.js', array('jquery'));
    	wp_deregister_script(  'avia-default', get_template_directory().'/js/avia.js', array('jquery'));
    	wp_enqueue_script( 'avia-default', get_stylesheet_directory_uri().'/js/avia.js', array('jquery'));
    	
    	}
    	add_action( 'wp_enqueue_scripts', 'wp_change_aviajs', 100 );

    Then clear your browser cache and any cache plugin, a couple of times and check.

    Best regards,
    Mike

    #1263909

    Hi Mike

    Belated thanks for this. I’ve just upgraded enfold (having held off because of the issues this caused).

    The issues recurred, and I then found your solution, which I have deployed.

    Presumably I now need to remember to update avia.js in the child theme and comment out those rows in order to keep things current.

    Thanks again,
    Matt

    #1263963

    Hi,
    Glad to hear this helped, unless there is anything else we can help with on this issue, shall we close this then?

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.