The MU forums have moved to WordPress.org

Needing to get blag name out of url (7 posts)

  1. Florimonte
    Member
    Posted 15 years ago #

    I'm moding a theme for MU, and I'm working on a way to get different graphics for the different blog (using the same theme) base on the url that calls WordPressMU. Exapmle being:
    mysterygirlz.01comics.com : I need the "mysterygirlz" part
    greenman.01comics.com : I need the "greenman" part
    superman.01comics.com : I need the "superman" part
    I gonna use that as the directory name that will contain the different graphics. I figured out that php code - bloginfo('name'); will give you the actual title name of the blog (what you've titled the blog) Such as the mysterygirlz.01comics.com blog title being Mystery Girlz. But I'm needing to get the mysterygirlz part out of the calling url- http://mysterygirlz.01comics.com
    There's gotta be a way other wise how does MU know which blog to pull out of the database.
    Any and all help would be greatly appreciated.

    Thomas @ 01Comics: Web Comics Online
    thomas@01comics.com

  2. lunabyte
    Member
    Posted 15 years ago #

    So is that to grab an image that you will let a user upload, like to their files directory?

    You could pull in the server variable $_SERVER['HTTP_HOST'] and then explode it by the [dot] which would give you an array of part[0], part[1], part[2] (subdomain, domain, and ext respectively).

    From there you can use the first array value which would be your domain.

    You may have to strip out http://, as I can't remember off the top of my head if thats included in the http_host var or not.

  3. Florimonte
    Member
    Posted 15 years ago #

    That would work- Here's the php code:
    $url_pieces = explode(".", $_SERVER['HTTP_HOST']);
    ....
    Then with the url being- http://mysterygirlz.01comics.net/ - $url_pieces[0] would be = mysterygirlz which works.
    I'm sure there is var in there that has this in it already. Was just looking for it. Trying to keep the code clean and dot doubling code.
    Still looking...

    Thomas @ 01Comics
    thomas@01comics.com

  4. lunabyte
    Member
    Posted 15 years ago #

    It is available in part, I think, but you have to call a function and then parse its return. I know get_current_site() returns the domain, so you'd still be exploding it.

    The only saving on using that function to get the domain would be if for some reason http_host fails to set. Other than that, there wouldn't be a difference.

    I might have not run across the function/var yet either. I usually don't dig real deep on something unless I have a specific need.

  5. strixy
    Member
    Posted 15 years ago #

    I haven't designed for MU yet, but is there any issue with using WP template tags in MU?

    ie <?php $blog_title = get_bloginfo('name'); ?>

    as per

    http://codex.wordpress.org/Template_Tags/get_bloginfo

  6. lunabyte
    Member
    Posted 15 years ago #

    Nope. All the template tags work as designed, for the most part. I haven't run across anything that didn't.

    Most functions do as well too. There are a few differences, naturally, but nothing out of the ordinary.

  7. andrea_r
    Moderator
    Posted 15 years ago #

    If they all need the same theme, just with different header graphics, why not create a functions.php page for that theme with a custom header option?

    or you just have to have it figure it out automatically? :)

    The other long and redundant way is to have three copies of the theme in questions, each named slighty different with a different header in each, and only accessable to the blog it matches.

About this Topic

  • Started 15 years ago by Florimonte
  • Latest reply from andrea_r