Forum Replies Created

Viewing 4 replies - 61 through 64 (of 64 total)
  • Thread Starter H?kan Wennerberg

    (@puffythepirateboy)

    Oh… silly me ?? I did not try to remove them since I thought they needed to be defined, but that seems to work. Why didn’t you say so in the first place! ??

    Thanks for the tip! Will do some testing.

    Thread Starter H?kan Wennerberg

    (@puffythepirateboy)

    A bit nicer coding… ??

    $current_id = config_get_network_ids($_SERVER['HTTP_HOST']);
    
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', $current_id['site_id'] );
    define( 'BLOG_ID_CURRENT_SITE', $current_id['blog_id'] );
    
    /**
     * Get the site_id and blog_id for the hostname being requested.
     * Defaults to site_id = 1 and blog_id = 1 if hostname was not found.
     *
     * @param string $hostname
     * @return array Key site_id (int) and blog_id (int)
     */
    function config_get_network_ids($hostname) {
        try {
            $networks = array('wp2.dev.local' => array('site_id' => 1, 'blog_id' => 1),
                              'wp3.dev.local' => array('site_id' => 2, 'blog_id' => 4));
            return $networks[$hostname];
        }
        catch (Exception $e) {
            // Default to 1, 1 if hostname was not found.
            return array('site_id' => 1, 'blog_id' => 1);
        }
    }
    Thread Starter H?kan Wennerberg

    (@puffythepirateboy)

    Found the problem, it was not a bug, WP just is not intended to be used for a multi-network installation even though small alterations would make it so.

    The code below is a static demonstration on how you could make multi-network work using, in this case WordPress 3.1 RC1:

    Original code in wp-config.php

    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', 'wp2.dev.local' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );

    Edit code to something similar for a static multi-network setup:

    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', config_get_current_site_id($_SERVER['HTTP_HOST']) );
    define( 'BLOG_ID_CURRENT_SITE', config_get_current_blog_id($_SERVER['HTTP_HOST']) );
    
    function config_get_current_site_id($hostname) {
        $site_id = array( 'wp2.dev.local' => 1,
                          'wp3.dev.local' => 2);
        return $site_id[$hostname];
    }
    
    function config_get_current_blog_id($hostname) {
        $blog_id = array( 'wp2.dev.local' => 1,
                          'wp3.dev.local' => 4);
        return $blog_id[$hostname];
    }

    This, however, should be swapped for code accessing the DB to get proper data.

    Thread Starter H?kan Wennerberg

    (@puffythepirateboy)

    The main WordPress installation is located at wp2.dev.local, then, to have multiple networks a new network is created in WordPress (wp3.dev.local) and that network domain name is added as a alias pointing to the same installation files.

    The idea is to have:

    my-first-network.com/user-blog-1/
    my-first-network.com/user-blog-2/
    my-first-network.com/user-blog-3/
    second-network.se/user-blog-1/
    second-network.se/user-blog-2/
    second-network.se/user-blog-3/

    All in a single WP install utilizing multiple networks for easy maintenance.

    As said previously, everything works as expected, EXCEPT, the new Network Admin area in 3.1-beta where the 302 loop starts on every network but the first one.

    The more I think of it, the more it seems like a WordPress bug rather than a Apache config error…

    Guess I have some code reading to do on Monday.

    Merry Christmas btw.! Santa is coming tonight in Sweden ??

Viewing 4 replies - 61 through 64 (of 64 total)