Jump to content

[SOLVED] How can i dynamically link buttons in tinymce editor based on geo-location?


Boost
 Share

Recommended Posts

Hi,

I'm a bit confused about where and how the geo-targeting should occur. For instance, I have page A with a button that will link to either page B (if you are in the US) or page C (if you are in the UK). My concern is how to ensure that the link points to the right page. I'm not worried about the geo-targeting code; I have that covered. My uncertainty lies in how to dynamically assign the correct link to the button. The challenge is that I'm using the TinyMCE editor for the copy, which includes the button. Is there a way to route the link through a hook or function that will determine the geo-targeting? Please feel free to ask any additional questions if my explanation is unclear.

Thanks!

Link to comment
Share on other sites

  • Boost changed the title to [SOLVED] How can i dynamically link buttons in tinymce editor based on geo-location?

I just used hanna code.

<?php namespace ProcessWire;

$country = getLocation(); // my geo-targeting function that returns the country iso two letter code
$creditUnion = "/solutions/credit-unions/";
$buildingSociety = "/solutions/building-societies/";

$pageLink = $country == 'GB' ? $buildingSociety : $creditUnion;
echo "<a class='uk-button uk-button-orange uk-border-pill uk-text-bold' href='" . $pageLink . "'>Learn More</a>";

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...