Search
Other Conditional Content questions
Forum

country detection not working, and also affected by joomla cache

Fabio Nobre's Avatar Fabio Nobre
Hello, my setup: Joomla 4.4.5, php 8.1, conditional content pro 5.1.6, geoip 6.1.0.

I cannot get it to work by country. It does work by continent. The other rules (dates, months..) work.

GEO database up to date, and I check that my country is detectable by my IP at the database supplier www.maxmind.com/en/geoip-api-web-services .

I also found another problem when testing with continent condition (which works). If one visitor from one continent loads the page, the content will be cached and another visitor from another continent will see the wrong content until the cache expires.

I used a similar extension in the past with Joomla 3 which worked perfectly, but it does not exist anymore. If it helps here are the old files (for inspiration...)

www.dropbox.com/scl/fo/dw5g72g9nedmu0gpw...6o3eswndkv02njv&dl=0

Thanks in advance
Peter van Westen's Avatar Peter van Westen ADMIN
If you have page caching on, then yes, that will affect Conditional Content and anything else that should be dynamic.
So make sure the content in which you use Conditional Content is not statically cached.
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Regarding the country condition, what do you get when going to this url?
regularlabs.com/geoip.php
Please post a rating at the Joomla! Extensions Directory
Fabio Nobre's Avatar Fabio Nobre
Hello Peter, thanks for the fast response.

We bought your extension to migrate from J3 to J4. Regarding disabling cache, I just checked and it was already completely disabled. In J4 this is possible: global configuration>system>cache = off. (in J3 there was a minimum 1 minute cache that we cannot disable).

regarding result of this URL regularlabs.com/geoip.php it is correct from my PC based in Brazil I get:

GeoIP Location Results for IP [177.21.104.15]
Continent Code SA
Continent South America
Country Code BR
Country Brazil
Region Codes CE
Regions Ceará
Postal Code 62580

and from my phone using a VPN connected to the netherlands, I get:

GeoIP Location Results for IP [217.23.3.92]
Continent Code EU
Continent Europe
Country Code NL
Country The Netherlands
Region Codes ZH
Regions South Holland
Postal Code 2671

I have created a test page at my J4 instance dev01.jeri.com/club/b/en/rl with the content:
==================
{show continents="South America"}this is a conditional test for //show continents="South America"//{/show}
{show continents="North America"}this is a conditional test for //show continents="North America"//{/show}
{show continents="Europe"}this is a conditional test for //show continents="Europe"//{/show}
{show countries="Brazil"}this is a conditional test for //show countries="Brazil"//{/show}
{show countries="Netherlands"}this is a conditional test for //show countries="Netherlands"//{/show}
{show countries="France"}this is a conditional test for //show countries="France"//{/show}
{show countries="Germany"}this is a conditional test for //show countries="Germany"//{/show}
{show months="june"}this is a conditional test for //show months="june"//{/show}
{show months="july"}this is a conditional test for //show months="july"//{/show}
==================
and I get continent and month correct, but no country. Both from my local and my vpn-dutch-ip.

thanks,
Peter van Westen's Avatar Peter van Westen ADMIN
Please use the editor button to get the correct syntax.
Please post a rating at the Joomla! Extensions Directory
Fabio Nobre's Avatar Fabio Nobre
May I also suggest to use the 2 letter country code instead of full country name in the future, avoids confusion (eg: "Netherlands" or "The Netherlands" ? )
Fabio Nobre's Avatar Fabio Nobre
Hi Peter, I did use the editor button for the content above

anything wrong with this syntax?

{show countries="Brazil"}test from Brazil{/show}
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version of Conditional Content and GeoIP from:
regularlabs.com/development-releases

PS: these should both work:
{show countries="Brazil"}test from Brazil{/show}
{show countries="BR"}test from Brazil{/show}
Please post a rating at the Joomla! Extensions Directory
Fabio Nobre's Avatar Fabio Nobre
Hi Peter,

The new release fixed the country problem, thanks.

Now I still have the cache problem. I still haven't found a way to set a page (or the entire site) with no cache. I have the joomla cache disabled as you can see in the settings on this screen grab prnt.sc/mBgv0yLJyO3H

However, it still seems to live for 1 minute, which makes the Geo condition feature un-usable, because if a visitor from France loads the page, and another visitor from Germany visits the same page in less than a minute, the German visitor will see content intended for the French audience. You can see this on the test page I created dev01.jeri.com/club/b/en/rl by using an IP from in/out Holland.

I have tried also to use the conditional code inside a custom module (because the custom module has its own cache setting) with no luck. Having a no-cache Joomla site seems to be a challenge as per my research, issues.joomla.org/tracker/joomla-cms/32989 and there could be a cache layer from the hosting provider too.

Would be great if your code could prevent loading cached content thru some php function, to solve this problem for Geo conditions.

Thanks for your attention,

Fabio
Peter van Westen's Avatar Peter van Westen ADMIN
You probably have the Page Cache system plugin enabled. That caches the entire page including all modules.
You don't want that plugin enabled.

Read for more on caching here: www.joomlabeginner.com/blog/tutorials/81...able-cache-in-joomla
Please post a rating at the Joomla! Extensions Directory
Fabio Nobre's Avatar Fabio Nobre
Thanks Peter. that did the trick, thanks.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription