ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Overriding template file basepath in index.php for an MSM site

February 07, 2011 12:14pm

Subscribe [3]
  • #1 / Feb 07, 2011 12:14pm

    beckermayer

    4 posts

    Hi there,

    I have the exact same question as the original poster to this closed thread. I’m using the MSM and, for the default site, setting ‘tmpl_file_basepath’ in config.php. For a second site I’ve added via the MSM, I’d like to override this path, so that I can store the second site’s templates with my other assets for the second site. According to the thread I linked to above, I should be able to do this in my second site’s index.php file. Here is what the custom config section of my second site’s index.php looks like:

    /*
     * --------------------------------------------------------------------
     *  CUSTOM CONFIG VALUES
     * --------------------------------------------------------------------
     *
     * The $assign_to_config array below will be passed dynamically to the
     * config class. This allows you to set custom config items or override
     * any default config values found in the config.php file.  This can
     * be handy as it permits you to share one application between more then
     * one front controller file, with each file containing different 
     * config values.
     *
     * Un-comment the $assign_to_config array below to use this feature
     *
     * NOTE: This feature can be used to run multiple EE "sites" using
     * the old style method.  Instead of individual variables you'll
     * set array indexes corresponding to them.
     *
     */
    //    $assign_to_config['template_group'] = '';
    //    $assign_to_config['template'] = '';
    //    $assign_to_config['site_index'] = '';
    //    $assign_to_config['site_404'] = '';
    //    $assign_to_config['global_vars'] = array(); // This array must be associative
    
    /**
     * If you are running the Multiple Site Manager, uncomment and assign the following variables 
     * See <a href="http://ellislab.com/expressionengine/user-guide/cp/sites/domainsetup.html">http://ellislab.com/expressionengine/user-guide/cp/sites/domainsetup.html</a>
     */
    $assign_to_config['site_name'] = 'guitar';
    $assign_to_config['cp_url'] = 'guitar-ee';
    $assign_to_config['site_url'] = 'guitar-ee';
    $assign_to_config['tmpl_file_basepath']   = 'Users/ekraft/Sites/guitar-ee/assets/templates';

    Despite that last line, my second site is still hanging onto the template path specified in the default site’s config.php file. Is there a different way I should be setting up my second site’s index.php?

    Thanks,

    Erik

  • #2 / Feb 08, 2011 5:15am

    John Henry Donovan

    12339 posts

    Erik ,

    Try removing it from the config.php and adding it in the first sites index file like your second.

  • #3 / Feb 08, 2011 11:29am

    beckermayer

    4 posts

    Thanks for the reply. Since originally posting, I’ve realized the problem is more global than just not being able to set tmpl_file_basepath through index.php for my second site. Basically, none of the config items I’m trying to set in index.php are being respected, for both my first and second MSM sites. Here’s what I’ve tried…

    (1) For my main site: I’ve reverted config.php to its original state, so things like tmpl_file_basepath and site_url are no longer being set here.

    (2) For my main site: in index.php, I’ve uncommented the three last lines in Custom Config Values and set them like so:

    $assign_to_config['site_name'] = 'default_site';
    $assign_to_config['cp_url'] = 'http://epic-ee/epicadmin';
    $assign_to_config['site_url'] = 'http://epic-ee/foo';

    (3) For my main site—when I go to General Configuration, it’s not pulling in the values I’m trying to set in index.php. (So the site URL here is http://epic-ee/ instead of the test value of ‘http://epic-ee/foo’ I set in index.php.)

    So it seems like the issue is that configuration items I’m trying to set in index.php are being ignored, even when there are no conflicting settings in the main config.php file. Anything I can try to force my sites to use the settings from index.php?

    Thanks,

    Erik

  • #4 / Feb 08, 2011 4:19pm

    Brandon Jones

    5500 posts

    Hi Erik,

    Which version and build of EE are you using? You might also check to make sure no server-side caching mechanisms are in play here.

  • #5 / Feb 08, 2011 5:17pm

    beckermayer

    4 posts

    Hi Brandon,

    I’m running Version 2.1.3, Build 20101220. I’m working in a pretty standard MAMP local dev environment, so I don’t think any server-side caching should be coming into play, but I’m not really a server guy, so if you have any specific suggestions for what I should be checking I’d appreciate it!

    Thanks,

    Erik

  • #6 / Feb 09, 2011 1:59am

    John Henry Donovan

    12339 posts

    Erik,

    For a standard MSM setup all you need to add to your second site’s index.php is $assign_to_config[‘site_name’] as per docs

    If you are masking admin access then that’s when $assign_to_config[‘cp_url’] comes into play

    For a second site I’ve added via the MSM, I’d like to override this path, so that I can store the second site’s templates with my other assets for the second site.

    Add your path in the cp for site 1 then just switch sites and update the path for site 2. Easy as that.

    Does that make sense?

  • #7 / Feb 09, 2011 12:58pm

    beckermayer

    4 posts

    Thanks John. What you’re saying does make sense, and indeed corresponds with how I’m currently doing things. The trick is that I’m trying to set things up to be as portable as possible across dev, stage, and production servers—these sites are going to be managed using git, and I’m trying to avoid a situation where I need to update a ton of control panel paths each time I export/import the database to a new environment.

    So my hope was I’d be able to do something like what is described here: http://eeinsider.com/articles/multi-server-setup-for-ee-2/ In theory, it seems like I should be able to set config variables in each MSM site’s index.php file. Then I would .gitignore the index.php files and set server-specific paths for each environment. Alas, any values I’m trying to set in index.php for either MSM site seems to be being ignored. I’m just trying to get to the bottom of whether this could be a bug, or an error with my assumption about how config variables set in index.php should work…

    Thanks,

    Erik

  • #8 / Feb 10, 2011 3:35am

    John Henry Donovan

    12339 posts

    Erik ,

    then I would suggest using the masked login technique and updating the config variables in the new admin.php file which comes from system/index.php and not the root index.php which is copied into the root of your MSM site.

  • #9 / Feb 10, 2011 12:36pm

    beckermayer

    4 posts

    Shoot. Still no dice: I followed the instructions here: http://ellislab.com/expressionengine/user-guide/installation/masked_cp_access.html and created an admin.php file for my second site. I’m able to login via the new admin.php file, so I think the CP masking itself is working fine, but it’s not pulling in any assign_to_config values I’m trying to set in admin.php. They’re being ignored the same way they were when I was trying to set them in index.php.

  • #10 / Feb 11, 2011 2:49am

    John Henry Donovan

    12339 posts

    Erik,

    I have a short memory. My apologies. I had tried this previously with a user and got nowhere. He did though. This was his solution

    Hope that helps

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases