• Resolved hudsontek

    (@hudsontek)


    This is potentially a great solution for me, thank you for making it. However, I’m not quite there yet…

    The problem is that if I enable country specific CSS and also enable the ‘disable caching’ I get the warning that no pages are cached.

    So is it possible to just add the country specific CSS on one page? because that’s all I need this for –?one sales page.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Benjamin Pick

    (@benjamin4)

    You can enable the AJAX mode (and add Frontend JS)- then the CSS class is still added on every page, but page caching is not disabled (the data is fetched via JS and stored in a cookie, so it will be only fetched once per visitor)

    Thread Starter hudsontek

    (@hudsontek)

    Oh thank you! this sounds great. So it’s just a matter of pasting in the provided frontend JS into the header or body of the page? I was put off thinking I had to write the JS myself.

    Will this cause an issue with having to prompt the user to share they location though? Or will it all still happen in the background?

    Thread Starter hudsontek

    (@hudsontek)

    I’ve got this all working. I just had to check those two boxes. So now the only issue is I only want that Ajax call on the sales page, and not globally. Any advice for that? is it possible?

    Plugin Author Benjamin Pick

    (@benjamin4)

    Not yet. I have added a shortcode [geoip_detect2_enqueue_javascript] in the current beta version – you can add this shortcode on that page instead of ticking “add Frontend JS”.

    Currently it will still add the classes on the other pages as well, I don’t know yet how to change this behavior without a backwards compatibility break. I still need to rethink how to structure the options of the plugins to make them more understandable.

    Thread Starter hudsontek

    (@hudsontek)

    Ah that’s a shame, thanks though. This was the closest plugin to the solution so far. I mean, it is working but I really only need it to work for that one page. Sometimes the Ajax request can take more than half a second, so it’s probably a bit unnecessary to load it, right?

    I did have a look in Ajax.php and on Line 111 it says: ‘Call this function if you want to register the JS script only for specific pages’

    Is this anything to do with what I might need?

    Plugin Author Benjamin Pick

    (@benjamin4)

    This is the function that the shortcode will call, yes.

    Oh, here is a workaround for you (this works with 3.2.1):
    – Uncheck the CSS option (as it enables the JS for the whole page)
    – Use the filter geoip_detect2_ajax_localize_script_data to re-enable CSS only for AJAX
    – and call geoip_detect2_enqueue_javascript() on the page where you need a JS.

    Or wait a week or so until I release 3.3.0 ??

    Thread Starter hudsontek

    (@hudsontek)

    OK much appreciated, this looks promising but I struggle with the implementation. I’m not a coder but I am an engineer, and so I get the gist.

    I’m more than happy to tip you for this –?just a little more info needed on ‘use the filter’ and how to call that function on the page

    Plugin Author Benjamin Pick

    (@benjamin4)

    Plugin Author Benjamin Pick

    (@benjamin4)

    I have tested it now, it should work in beta. Can you please install the beta plugin as described in the wiki, and then:

    – uncheck “Add a country-specific CSS class to the <body>-Tag.”
    – uncheck “Add JS Helper functions to all pages.” if checked
    – check “Add a country-specific CSS class to the <body>-Tag (via AJAX).”
    – and put [geoip_detect2_enqueue_javascript] into the sales page

    Plugin Author Benjamin Pick

    (@benjamin4)

    I have released 3.3.0 now. Tell me if it doesn’t work …

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Add country specific CSS class to only one page’ is closed to new replies.