Jump to:

3433 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » variable from google ads only works on page refersh

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

Page: 1
Go to End
Author Topic: 295 Views
  • neilos
    Avatar
    Community Member
    19 Posts

    variable from google ads only works on page refersh Link to this post

    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();
    ?>

    295 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.