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.

Prefix ignored in Channel module?

September 01, 2011 8:58am

Subscribe [1]
  • #1 / Sep 01, 2011 8:58am

    0to9 Digital

    5 posts

    I’ve set up my base ExpressionEngine install with a relatively simple staging/production system which relies on the database prefix to seperate live from staged content.

    Using NSM Config bootstrap, I’m using, for example, a prefix “live_” for my live site, and prefix “exp_” for my staging site; I’ve used the exp_ prefix to install EE, and then set up the live_ prefix later.

    To my horror, though, I found out that everything in the channel module (mod.channel.php) is hardcoded to use the exp_ prefix! This means I have to edit the core files every time I want EE to take into account the prefix I want to get content from.

    Can this be confirmed, explained, and if it’s indeed the case, possibly be turned into a feature request?

  • #2 / Sep 01, 2011 4:22pm

    Lisa Wess

    20502 posts

    Hi metrodc, welcome to our community!

    EE does some on the fly aliasing and rearranging of those prefixes to match what you’ve set.  Did you set the prefix via config.php as well as in the database?

  • #3 / Sep 01, 2011 4:30pm

    0to9 Digital

    5 posts

    I did; I set up a base prefix (exp_) whilst installing, and set up a dynamic one for my live site (based on the HTTP host).

    So you’re saying I set it once, and during install, it’s set up to use this prefix I chose. Shame I can’t change this later, though, at least not “on-the-fly” dynamically.

    ( Just to clarify what I have set up here:

    I have a prefix “exp_” that I installed EE with, and a prefix “live_” that I put my live data in. I have a syncing system set up where I copy the contents of the “exp_” tables to the “live_” tables, and I want to point the live site to those “live_” tables.

    I do this by checking the URL; if it contains “staging” (e.g. http://staging.site.com), or if you’re in the CP, it switches to the “exp_” tables, and if it doesn’t, it chooses the “live_” prefix.

    (I have other systems in place to seperate uploads and css/js assets ).

    Since I cannot dynamically switch the prefix in the mod.channel.php file, I have to modify it with a if/else that sets a prefix depending on the URL and store it in a variable, and replace “exp_” everywhere with, for example, $this->prefix. )

  • #4 / Sep 01, 2011 4:50pm

    Lisa Wess

    20502 posts

    You can change it later but you have to tell EE so - via config.php.  I’m trying to ascertain if you have done that or not. =)

    As far as what you have enacted here, it sounds like you’ve hacked the core and done something here that is beyond what we can support.  Generally I’d recommend two databases - one live, one staging, and go at it that way.

  • #5 / Sep 01, 2011 4:56pm

    0to9 Digital

    5 posts

    I know I can change it later; that changes it everywhere, though, right? Can’t change it on-the-fly, I don’t want to just change it, I want to change it dynamically, based on the URL.

    Two databases is the next best thing, and if it’s the only way, I’ll certainly try that. Trying to come up with a flexible way to set up my staging/production theory so to speak, and not everyone has two databases at their disposal.

    You’ve answered my question, though, and for that I thank you 😊 I realize you can’t and shouldn’t support changes to your core, but I might see if I can turn this into a feature request later; I can see more advantages to not having the prefix aliassed into code in a non-dynamic way (though I certainly see the disadvantages as well).

    Anyway, thanks a lot, I guess I’ll go with the 2-databases-approach in the future.

  • #6 / Sep 01, 2011 4:59pm

    Lisa Wess

    20502 posts

    Yes, you would change it for that installation using config.php.

    if you’re using one installation with different database tables, things can get confusing pretty quickly.  The kind of dynamic switching you’re doing is well beyond what we can offer as part of our standard technical support offering.

    A feature request would be a great idea; our team is also well aware of the need for better ability to deploy between staging and live, and it is something we hope to improve upon in the future.

    I don’t want to shut this down as it is a good conversation, so I’m going to shift it down to Community Help. If you do come up with a solution you like, I’d love to encourage you to share that with our community. =)

    Thank you!

  • #7 / Sep 01, 2011 5:01pm

    0to9 Digital

    5 posts

    I will definitely share a solution if I come up with one. I’m going to see if I can figure out a way to switch tables without having multiple databases and hacking the core files. Always want to be able to update EE without any problems, of course!

    I’ll stay in touch, and thanks again.

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

ExpressionEngine News!

#eecms, #events, #releases