Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors produced when forceIp set in geomete.php #4

Closed
webwisecom opened this issue Jan 2, 2019 · 1 comment
Closed

Errors produced when forceIp set in geomete.php #4

webwisecom opened this issue Jan 2, 2019 · 1 comment

Comments

@webwisecom
Copy link

webwisecom commented Jan 2, 2019

I've installed geomete by following the instructions provided. As I'm working locally I've set my forceIp to my local IP address as follows:

return [ 'forceIp' => 'IP-ADDRESS-HERE' ];

When I add the following to my twig template {{ craft.geomate.country }} and run it I receive the following error:

PHP Recoverable Error – yii\base\ErrorException
Object of class GeoIp2\Model\Country could not be converted to string

Any advise on how to sort this would be greatly appreciated.

@aelvan
Copy link
Contributor

aelvan commented Jan 2, 2019

The error is just due to you trying to output the value that craft.geomate.country edits, directly. As the error message states, this is a complete object of type GeoIp2\Model\Country, which you need to drill into to get exactly what you want. To get an idea of what information is vailable, you can use dump() if you're in devMode, ie {{ dump(craft.geomate.country()) }}.

Some examples:

{% set countryData = craft.geomate.country() %}
{{ countryData.country.name }}<br>
{{ countryData.country.isoCode }}<br>
{{ countryData.country. isInEuropeanUnion }}<br>
{{ countryData.continent.name }}<br>

You can also learn more from looking at the models and records of the underlying Maxmind DB library source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants