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.

use path.php variables in config.php does not work in the CP

December 17, 2010 6:27am

Subscribe [6]
  • #1 / Dec 17, 2010 6:27am

    We have an EE 1.7 install running MSM, each site being a different linguistic version of our website. Some templates are different for each site. These are stored in subfolders in the templates/ folder (/templates/en/, templates/fr/, etc.). A path.php global variable called current_lang is used in order for the front end to load the correct template.

    In our path.php file

    $global_vars = array(
        'variable'    => 'value',
        'current_lang'    => 'en'
    ); // This array must be associative

    In our config.php file:

    $conf['tmpl_file_basepath'] = $conf['server_path']."/system/templates/".$global_vars['current_lang']."/";

    This works for the front end without any problem.

    On the CP side, it doesn’t work. Whatever the website in MSM, the template base path outputs as: “/ee-admin/templates//”. A var_dump($global_vars) shows that the value of the array is “null” in the CP ... I am guessing because the CP does not read path.php.

    Output is correct on the front end:

    'current_lang' => string 'en' (length=2)

    Is there a way to make it work so our newly created templates saved as files are saved / created in the correct folder?

    Currently, I am commenting out the line overriding the tmpl_file_basepath in config.php, set it manually in the CP, create my templates, uncomment the line and repuload config.php, which is not really convenient.

  • #2 / Dec 17, 2010 9:43am

    Steven Grant

    894 posts

    I don’t think so. I’ve looked at ways of including path variables within the CP before and couldn’t find a way to do it. IIRC the only variable available in the CP is {site_url}

    It would be super handy though.

  • #3 / Dec 17, 2010 10:09am

    Hi Steven,

    Thanks for chiming in.

    That’s what I suspected (CP does not read path.php methink) ... but I thought that maybe there was a clever bit of PHP wizardry that could help here. Since I am far from a PHP expert myself, I figured I would ask.

  • #4 / Dec 17, 2010 10:25am

    Steven Grant

    894 posts

    They must get assigned somewhere though if one is able to use {site_url} within the CP.

    This was an @boyink article http://www.train-ee.com/courseware/free-tutorials/comments/use-variables-in-control-panel-settings

  • #5 / Dec 17, 2010 11:00am

    Mhhhh.

    I think this is a completely different story:

    1. I might be wrong but {site_url} and {homepage} are out of the box default variables that you can use in your templates and in the CP. These are not user created variables relying on path.php being parsed > work in the CP.

    2. What I want to do is being able to use these vars in config.php overrides, not in the CP itself.

    Let’s hope some php wizard can help ...

  • #6 / Dec 17, 2010 11:12am

    Steven Grant

    894 posts

    I’m not familiar with MSM, does it have only 1 config.php?

  • #7 / Dec 18, 2010 2:23pm

    Greg Salt

    3988 posts

    Hi International Polar Foundation,

    If you are using MSM then you can set a different template save path for each site that you have created. If you go to Admin > Template Preferences and switch between sites then each path can be different. You would have to remove that config item though because that would set it for all sites. Would that work for you?

    Cheers

    Greg

  • #8 / Dec 19, 2010 3:33pm

    Steven Grant

    894 posts

    Just remembered why I wanted to do this, I wanted someway to display the environment I was working on within the CP and embed that intoLG SIte Name extension

  • #9 / Dec 20, 2010 4:46am

    Hi there Greg,

    Yep, that’s what I do right now (see first post) and it works of course. Was hoping to find a somewhat more convenient approach relying on files. My problem was that the approach that works on the front end (using path.php variables) does not work for the CP, since path.php variables are apparently not available on the CP side.

    Was thus wondering if there was any other approach I could take besides what I already do, which is just what you suggested. As I said, I am a bit of a PHP noob, so I might have missed something.

    Anyway, thanks for passing by and dropping me a line, and ... Merry Xmas !

  • #10 / Dec 20, 2010 6:12pm

    Brandon Jones

    5500 posts

    Hi International Polar Foundation,

    That’d be an interesting feature request. What you’re doing now is your best bet, I think, though I’d be happy to move this over to the CodeShare Corner if you’d like. Just let me know!

  • #11 / Dec 21, 2010 4:53am

    Jérôme Coupé

    122 posts

    Dear Brandon,

    Thanks for stopping by. Feature request posted.

    Have a good holiday season !

  • #12 / Dec 21, 2010 4:25pm

    Ingmar

    29245 posts

    Does that clear the issue up for you, IPF?

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

ExpressionEngine News!

#eecms, #events, #releases