Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Changing Site Content depending on Domain

  • 07-06-2005 10:00am
    #1
    Registered Users, Registered Users 2 Posts: 2,170 ✭✭✭


    Hey guys,

    I am working on a site that has two domains pointing to it. For the sake of an example, let's say the domains are FlyAir.com and FlyAer.com. Everywhere on the site that the words FlyAir are mentioned, the client wants to swap the text depending on the domain.

    This isn't a problem in itself, the site runs on PHP and it's easy to tell which domain the user has typed in to access the site and change stuff accordingly. The problem is more that the text is static HTML and I need to find a way of dynamically identifying instances of FlyAir / FlyAer in the text and changing them.

    Having seen some websites where they use JavaScript to detect words in an article / post and linking them to a sponsor, I was wondering if a similar approach would work? Maybe someone has a link to a tutorial for something like this? I haven't been able to find anything concrete really so I'm basically fishing for ideas here. Feel free to add your 2 cents worth, it will be appreciated!


Comments

  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    It sounds like it would be best to do it server-side ie. based on the requested URI
    Doing it client-side sounds like it could be very messy


  • Closed Accounts Posts: 1,819 ✭✭✭K!LL!@N


    I'd do it with PHP myself.
    Should be easy enough to replace the text, with whatever you like and then output it to HTML.
    I'd imagine it'd be quite messy to do it with Javascript.

    Killian


  • Registered Users, Registered Users 2 Posts: 2,170 ✭✭✭Serbian


    blacknight wrote:
    It sounds like it would be best to do it server-side ie. based on the requested URI
    Doing it client-side sounds like it could be very messy

    Yeah, that is what I intended to do, but I have been a bit thrown by the fact that the page is static HTML. I don't suppose anyone knows if it's possible to load a static HTML content into a buffer with PHP and then have their wicked way with the content (e.g. Finding and replacing text :p)? I remember reading about this somewhere, but I can't remember now.


  • Closed Accounts Posts: 1,819 ✭✭✭K!LL!@N


    You should find the file stuff in the PHP manual.
    There are a couple of way of reading in files, so whichever one suits.
    And you can probably just use str_replace to change the string.
    If the html is going to be static though, why not just keep two copies and have php redirect to the appropriate page when the URI is detected.

    Or, turn the html page into a php page and then you don't have to worry about reading in the file and no need for redirection, just have php serve up the appropriate string when it detects the URI.

    Killian


  • Registered Users, Registered Users 2 Posts: 2,170 ✭✭✭Serbian


    Okay, unlike Bono, I have found what I'm looking for. You can read all about it here:

    http://php.mirrors.esat.net/manual/en/function.ob-start.php

    Interesting that esat.net is hosting the PHP manual.


  • Advertisement
  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Serbian wrote:
    Interesting that esat.net is hosting the PHP manual.
    You're automatically bounced to a local mirror. Heanet mirrors PHP too, or at least they used to.

    adam


  • Registered Users, Registered Users 2 Posts: 2,170 ✭✭✭Serbian


    Oh yeah, I saw that. Just usually is says ie.php.net or something along those lines. Now you see a completely new domain.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Esat mirror stuff in a few different ways, for example most FTP archives are available via HTTP too. The PHP site shouldn't have redirected you to that hostname though, they rely on .php.net cookies for some functionality, so if you didn't find it in another way you should report it as a bug.

    adam


Advertisement