Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

variable from google ads only works on page refersh


Go to End


752 Views

Avatar
neilos

Community Member, 19 Posts

27 October 2012 at 12:53am

Hi,

I am trying to get a variable from various google location ads to change the phone number depending on the ?number=xxx from the ad.

The number displays a default value unless the page is refreshed, then the variable is displayed.

Is there a better way of doing this that will display the variable number without the need for a page refresh?

In page.ss

<% if phonenumber %>$phonenumber <% else %>0800 xxx xxx<% end_if %>

In page.php

public function Phonenumber() {
	 include('defines.php');
return strip_tags (Session::get ('number'));
}

And defines.php

<?php

ob_start();
if (!isset($_SESSION)) {
@session_start();
}
if (!isset($_SESSION['number']))
  {
  $phonenumber = $_GET['number'];
  $_SESSION['number'] = $phonenumber;
	  }

ob_end_flush(); 
?>