1

I'm currently working in a development server and have certain conditions in my templates that rely on, say, entry_id. When I migrate the site to a production server, that entry_id is bound to change.

What's an effective approach to handling these environmental variables?

  • Why would the entry id change? If you clone your dev server database to your production database environment, those primary keys will stay the same on data insert. – jrothafer Apr 7 '15 at 15:36
4
+50

You have a few options.

  1. While in development, frequently clone your database from production to dev, which reduces the chance that they will diverge significantly.
  2. Try to reduce situations where you rely on the entry ID. Find other things that you can control better, like making a decision based on some distinguishing data in the entry itself, or if you use Structure, setting the template to something special.
  3. If you use master.config, create a global that defines which entry_id to use, and set it per environment, just like database settings are set per environment.

At the agency I work for, we've used all of these techniques. It's just a question of which is appropriate for your current task.

  • 2
    An additional tip is to use the url_title, not entry_id (use the parameter in the channel:entries for url_title="") - then you can control it across environments. As Bryan suggested in point 1 - create the entries first on production and bring down to dev. – Peter Lewis Apr 6 '15 at 9:31
  • 1
    Also see this post, which also covers deployment and code/content flow : expressionengine.stackexchange.com/questions/45/… – Blatant Apr 9 '15 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.