<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0" xml:base="https://admin.frontmag.no/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <title>Frontmag</title>
 <description>Articles by Planetdrupal</description>
 <link>https://admin.frontmag.no/</link>
 <atom:link rel="self" href="https://admin.frontmag.no/tag/planetdrupal/rss" />
 <item> <title>Show external JSON data in Drupal Views</title>
 <link>https://frontmag.no/artikler/utvikling/show-external-json-data-drupal-views</link>
 <description>&lt;p&gt;If the data you want follows a JSON structure, &lt;a href=&quot;http://www.frontkom.no/drupal&quot; target=&quot;_blank&quot;&gt;Frontkom&lt;/a&gt; has built a handy module that can easily help you: &lt;a href=&quot;https://www.drupal.org/project/views_json_query&quot;&gt;Views Query JSON&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This module basically fetches JSON data from an URL and parses as a flat data structure to be used on Views displays.&lt;/p&gt;

&lt;p&gt;So, how to use it? Install the module and enable it.&lt;/p&gt;

&lt;p&gt;Create a new view and choose Json option at &lt;em&gt;Show&lt;/em&gt; select box:&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-02-14_at_16.34.29.png?itok=4JgImXpv&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then fill the rest of the fields as you normally do.&lt;/p&gt;

&lt;p&gt;Now you need to define from where the data is coming. Click on &lt;em&gt;Advanced&lt;/em&gt; and then &lt;em&gt;Query settings: Settings&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-02-14_at_16.36.38.png?itok=jRuqKRMC&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Fill the &lt;em&gt;Json File&lt;/em&gt; text field with the source URL:&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-02-20_at_15.43.00.png?itok=8HBCnwiv&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You should fill &lt;em&gt;Row Apath&lt;/em&gt; field with the data key you want to retrieve. For example, the JSON data we’re working on has the following structure:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br /&gt;
  &#039;persons&#039;:[&lt;br /&gt;
    {&lt;br /&gt;
      &#039;firstName&#039;: &#039;Geir&#039;,&lt;br /&gt;
      &#039;lastName&#039;: &#039;Gulland&#039;,&lt;br /&gt;
      &#039;position&#039;: &#039;CEO &amp;amp; partner&#039;,&lt;br /&gt;
      &#039;imageUrl&#039;: &#039;http://www.frontkom.no/img/profiles/Geir.jpg&#039;,&lt;br /&gt;
      &#039;contact&#039;:{&lt;br /&gt;
        &#039;facebook&#039;: &#039;https://www.facebook.com/geir.gulland&#039;,&lt;br /&gt;
        &#039;linkedin&#039;: &#039;http://www.linkedin.com/profile/view?id=6151058&#039;&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
...&lt;br /&gt;
]}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So you should use &lt;em&gt;persons&lt;/em&gt; as the row apath.&lt;/p&gt;

&lt;p&gt;Be aware that for a structure like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[&lt;br /&gt;
  {&lt;br /&gt;
    ‘firstName’: ‘Marco’,&lt;br /&gt;
    ‘lastName’: ‘Fernandes’,&lt;br /&gt;
    ‘contact’: {&lt;br /&gt;
      ‘email’: ‘marco@example.com’,&lt;br /&gt;
      ‘phone’: ‘123456789’&lt;br /&gt;
    },&lt;br /&gt;
  ...&lt;br /&gt;
]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The find method used on row apath won’t work because no key is given for the collection. This issue already being addressed by the maintainers of the module.&lt;/p&gt;

&lt;p&gt;Now, let’s get some values into our view table. By default, one empty field is added to your view fields so just click on that one:&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-02-20_at_15.49.58.png?itok=AoZUxpcQ&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Give a name to the label and on &lt;em&gt;Key Chooser&lt;/em&gt; field, well, choose the key:&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-02-20_at_15.51.04.png?itok=kfHkrAva&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you want to render an image from an url just enable the Rewrite results when editing the field:&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-03-06_at_16.56.27.png?itok=5El7Khc5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Apply, save et voilá! External data on your site, always up-to-date!&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/inline_full/public/screen_shot_2015-03-06_at_16.48.28.png?itok=vGWu3btW&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As you can see on the example data structure we have a node “contact” that contains email and phone attributes. How do you fetch those fields? Simple, on &lt;em&gt;Key Chooser&lt;/em&gt; field just fill contact/email or contact/phone. And you can do that on any number of levels, e.g. contact/email/work, contact/phone/work/primary.&lt;/p&gt;

&lt;p&gt;And that’s all to it. Very simple stuff but definitely very handy.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
</description>
 <enclosure url="https://admin.frontmag.no/sites/default/files/styles/large/public/img/2015-03/json-to-drupal.jpg?itok=F3uQy2AN" length="16155" type="image/jpeg" />
 <guid isPermaLink="false">Node-171</guid>
 <pubDate>Fri, 20 Feb 2015 16:56:02 +0100</pubDate>
 <source url="https://admin.frontmag.no/tag/planetdrupal/rss">Frontmag</source>
</item>
 <item> <title>Improve your Drupal media content editing experience with Mediadesk</title>
 <link>https://frontmag.no/artikler/utvikling/improve-your-drupal-media-content-editing-experience-mediadesk</link>
 <description>&lt;p&gt;Drupal is a extremely powerful tool but we’ve all had to deal with some fair criticisms regarding user experience. Some of them are being addressed in Drupal 8 and others with the help of contrib modules.&lt;/p&gt;

&lt;p&gt;When it comes to file management, &lt;a href=&quot;https://www.drupal.org/project/media&quot;&gt;Media&lt;/a&gt; module provides us a number of features that make it almost mandatory for any Drupal project.&lt;/p&gt;

&lt;p&gt;However, when we’re dealing with content types with a lot of image files, editing a node may become somewhat cumbersome. Fortunately there are a number of modules that extend Media core framework features. &lt;/p&gt;

&lt;p&gt;We tried a couple of these and found out that setting up &lt;a href=&quot;https://www.drupal.org/project/media_desk&quot;&gt;Mediadesk&lt;/a&gt; can provide us a better media management workflow, especially when we pair it with &lt;a href=&quot;https://www.drupal.org/project/plupload&quot;&gt;Plupload&lt;/a&gt; and &lt;a href=&quot;https://www.drupal.org/project/manualcrop&quot;&gt;Manual Crop&lt;/a&gt; modules.&lt;/p&gt;

&lt;p&gt;Mediadesk allows you through the &#039;Media Desk Selector&#039; widget to set a field for central management of images , where you can upload or select those that you wanna use on the node edit form and from there drag &amp;amp; drop them on all the image fields (as long as they use use &#039;Media Desk image&#039; widget).&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;media-image&quot; src=&quot;https://static.frontmag.no/sites/default/files/styles/inline_full/public/img/mediadesk-playground.png?itok=oRcsHblo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If set up with Plupload you’ll also have the change to upload multiple files at once (via drag &amp;amp; drop or from the browser dialog)&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;plupload&quot; class=&quot;media-image&quot; src=&quot;https://static.frontmag.no/sites/default/files/styles/inline_full/public/plupload.png?itok=km6bzoJ0&quot; /&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;and with Manualcrop, you get image cropping through the image editing interface.&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;manualcrop&quot; class=&quot;media-image&quot; src=&quot;https://static.frontmag.no/sites/default/files/styles/inline_full/public/manualcrop.png?itok=js5uVi72&quot; /&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Give it a try and see how it fits in some of your projects. We’re quite happy with this current setup.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
</description>
 <enclosure url="https://admin.frontmag.no/sites/default/files/styles/large/public/img/mediadesk-playground.png?itok=0pyU1SuU" length="87416" type="image/png" />
 <guid isPermaLink="false">Node-170</guid>
 <pubDate>Fri, 20 Feb 2015 11:15:22 +0100</pubDate>
 <source url="https://admin.frontmag.no/tag/planetdrupal/rss">Frontmag</source>
</item>
 <item> <title>Drupal profile moderation</title>
 <link>https://frontmag.no/artikler/utvikling/drupal-profile-moderation</link>
 <description>&lt;p&gt;For content moderation in Drupal we have it easy, since we have revisioning built into the Drupal core. But what if you need to moderate users profile information? &lt;/p&gt;

&lt;p&gt;A typical use could be that profile data is to be shown to other users, and an admin might need to go through changes to verify them.&lt;/p&gt;

&lt;p&gt;For complex user profiles in Drupal the module of choice is &lt;a href=&quot;https://drupal.org/project/profile2&quot;&gt;Profile2&lt;/a&gt;, and you can now do your moderation to these profiles using the &lt;a href=&quot;https://drupal.org/project/profile2_moderation&quot; target=&quot;_blank&quot;&gt;Profile Moderation module&lt;/a&gt; (made by Frontkom).&lt;/p&gt;

&lt;h2&gt;Set up&lt;/h2&gt;

&lt;p&gt;First of all you need to install/enable the &lt;a href=&quot;https://drupal.org/project/profile2&quot; target=&quot;_blank&quot;&gt;Profile2 module&lt;/a&gt;. Unfortunely this module still misses a revision mechanism (like we see on nodes/content) but don&#039;t worry, there&#039;s a patch for it!&lt;/p&gt;

&lt;p&gt;The Drupal community is working hard to &lt;a href=&quot;https://drupal.org/node/1043128&quot; target=&quot;_blank&quot;&gt;implement revisions on the Profile module&lt;/a&gt; and already &lt;a href=&quot;https://drupal.org/files/profile2-revisions-1043128-55.patch&quot; target=&quot;_blank&quot;&gt;published a patch&lt;/a&gt; to make this possible.&lt;/p&gt;

&lt;p&gt;To apply the patch you can &lt;a href=&quot;https://drupal.org/patch/apply&quot; target=&quot;_blank&quot;&gt;check here&lt;/a&gt; to know more details on how to. Basically just download the patch and then on your terminal go to Profile2 module location (usually sites/all/modules/profile2/) and then run the following command:&lt;/p&gt;

&lt;pre&gt;
$ patch -p1 &amp;lt; [download_dir]/profile2-revisions-1043128-55.patch&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;There. Now user profiles supports revisions.&lt;/p&gt;

&lt;p&gt;Next, just install/enable the latest version of &lt;a href=&quot;https://drupal.org/project/profile2_moderation&quot; target=&quot;_blank&quot;&gt;Profile 2 Moderation module&lt;/a&gt;. And at admin/people you will see a new tab &quot;Profiles Moderation&quot;. This is where you moderate the profiles.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img alt=&quot;screen_shot_2014-02-18_at_10.51.02.png&quot; height=&quot;556&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/scald_drop/public/atoms/images/2014-02/screen_shot_2014-02-18_at_10.51.02.png?itok=b9FI3XtZ&quot; title=&quot;screen_shot_2014-02-18_at_10.51.02.png&quot; width=&quot;990&quot; /&gt;&lt;/figure&gt;&lt;div class=&quot;image&quot;&gt; &lt;/div&gt;

&lt;p&gt;&lt;span&gt;But first you need to enable moderation on the profile types you want to moderate.&lt;/span&gt;&lt;/p&gt;
&lt;!-- scald=111:sdl_editor_representation --&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img alt=&quot;screen_shot_2014-02-18_at_10.49.20.png&quot; height=&quot;556&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/scald_drop/public/atoms/images/2014-02/screen_shot_2014-02-18_at_10.49.20.png?itok=R6pjCjFy&quot; title=&quot;screen_shot_2014-02-18_at_10.49.20.png&quot; width=&quot;990&quot; /&gt;&lt;/figure&gt;&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;span&gt;Now, every time a user changes his profile, the revisions will pop up on Profile Moderation list waiting to be moderated.&lt;/span&gt;&lt;/p&gt;
&lt;!-- scald=113:sdl_editor_representation --&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img alt=&quot;screen_shot_2014-02-18_at_11.18.01.png&quot; height=&quot;556&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/scald_drop/public/atoms/images/2014-02/screen_shot_2014-02-18_at_11.18.01.png?itok=7n0mtHaX&quot; title=&quot;screen_shot_2014-02-18_at_11.18.01.png&quot; width=&quot;990&quot; /&gt;&lt;/figure&gt;&lt;p&gt; &lt;/p&gt;

&lt;p&gt;By default, administrators have the permission to moderate profiles but you can change the permissions settings at admin/people/permissions (look for Profile Moderation).&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img alt=&quot;screen_shot_2014-02-18_at_11.24.29.png&quot; height=&quot;67&quot; src=&quot;http://admin.frontmag.no/sites/default/files/styles/scald_drop/public/atoms/images/2014-02/screen_shot_2014-02-18_at_11.24.29.png?itok=Nljsf28-&quot; title=&quot;screen_shot_2014-02-18_at_11.24.29.png&quot; width=&quot;640&quot; /&gt;&lt;/figure&gt;&lt;p&gt; &lt;/p&gt;

&lt;p&gt;And that&#039;s it. Pretty simple, uh?&lt;/p&gt;

&lt;p&gt;Just one final note: As I said, the profile revisions and this module are still under heavy development. Already reached some stability but it still has some things missing like image/file field support and probably some other stuff. So, are you a developer? Then come and join us. Drupal community is made of &lt;span&gt;really&lt;/span&gt; cool people :).&lt;/p&gt;
</description>
 <enclosure url="https://admin.frontmag.no/sites/default/files/styles/large/public/profile-moderation.jpg?itok=V_aonuvr" length="10384" type="image/jpeg" />
 <guid isPermaLink="false">Node-118</guid>
 <pubDate>Tue, 18 Feb 2014 11:53:28 +0100</pubDate>
 <source url="https://admin.frontmag.no/tag/planetdrupal/rss">Frontmag</source>
</item>
 <item> <title>Great tool: simplytest.me</title>
 <link>https://frontmag.no/artikler/utvikling/great-tool-simplytestme</link>
 <description>&lt;p&gt;Quick preview of releases from drupal.org just got easier - &lt;a href=&quot;https://simplytest.me/&quot; title=&quot;simplytest.me&quot;&gt;simplytest.me&lt;/a&gt; is here!&lt;/p&gt;

&lt;p&gt;Say you want to preview a distribution. Or a theme. Or a module. Or even a patch. This service gives you a simple and quick setup of a sandbox, existing for 30 minutes for anonymous users or 60 minutes for logged in users. You can even request more time if you really need it.&lt;/p&gt;

&lt;p&gt;This is cool. Try it!&lt;/p&gt;
</description>
 <enclosure url="https://admin.frontmag.no/sites/default/files/styles/large/public/screenshot.png?itok=R-XwnbzW" length="130505" type="image/png" />
 <guid isPermaLink="false">Node-85</guid>
 <pubDate>Thu, 21 Mar 2013 09:58:10 +0100</pubDate>
 <source url="https://admin.frontmag.no/tag/planetdrupal/rss">Frontmag</source>
</item>
 <item> <title>Safer Drupal development with custom settings</title>
 <link>https://frontmag.no/artikler/utvikling/safer-drupal-development-custom-settings</link>
 <description>&lt;p&gt;In a development situation with an increasing number of developers involved and site is live long ago, it is becoming ever more important to draw a clear separation line between a developer environment &amp;amp; the main production environment. All Drupal developers are still more or less human (will there ever be a module for that?), so there will always be room for mistakes. One of the situations mistakes can happen is where you believe you are completely isolated, when developing locally.&lt;/p&gt;

&lt;p&gt;Say you are creating a new part of an existing site on your local Unix/Win/Whatever machine, and want to test whatever you&#039;ve currently implemented. You browse pages, search for stuff and click some buttons. This is a big site, and without knowing all the structure behind the site you click around like an elephant stepping into an egg salad. Without even noticing, you accidentially sent some mails to all the managers, updated some webservices with new shiny .tld addresses and corrupted some search results on prod. Let alone triggered Cron, and updated a bunch of non-existing-on-prod commerce orders on a remote service now sending out all those lederhosen to someone named Dsdsfsfd in Iceland. All when sitting inside your local bubble. Dsdsfsfd is of course happy, store manager not so much. :)&lt;/p&gt;

&lt;h3&gt;Stuff to consider&lt;/h3&gt;

&lt;p&gt;In our company we do a great deal of work on commerce sites, and in that relation, keeping production isolated from everything else is a total must. The local environment should be completely testable, without affecting live. So while developing or deploying new modules &amp;amp; implementations, there are a few issues one needs to have in mind:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;u&gt;How will these implementations interact on production?&lt;/u&gt;&lt;br /&gt;
	Determine if your implementation does anything that affect stuff outside the main database.&lt;/li&gt;
	&lt;li&gt;&lt;u&gt;Does it call any external services?&lt;/u&gt;&lt;br /&gt;
	Of course, querying for a weather forecast via public service is a no-brainer, but when integrating and communicating with external services we need to really stop and think.&lt;/li&gt;
	&lt;li&gt;&lt;u&gt;Are any service provider&#039;s data affected by your calls?&lt;/u&gt;&lt;br /&gt;
	Google analytics is an excellent example where data can be directly affected from local dev, not to mention search api indexes &amp;amp; order systems.&lt;/li&gt;
	&lt;li&gt;&lt;u&gt;Does everybody else in my team know what I&#039;m implementing??&lt;/u&gt;&lt;br /&gt;
	If something new is implemented and it can have implications when not on prod, you have the option to inform everybody &quot;don&#039;t do this and configure that&quot;. But you can also just try to think &quot;this will be used locally, do I need to prevent anything bad from happening by making it aware of what environment it is triggered in?&quot;.&lt;/li&gt;
	&lt;li&gt;&lt;u&gt;Can the designed workflow be followed / emulated effectively on local development without affecting production?&lt;/u&gt;&lt;br /&gt;
	Stuff like proprietary maps and such just stops working when not having an API key. That&#039;s not affecting production, but it is an inconvenience when maps stop working on local every time you pull a fresh database from production to work with. One more automated local transformation = 1 less dev headache.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;There should always be a measure in place to separate prod &amp;amp; stg. Relying on all other devs knowing as good as yourself what exactly you are doing is mistakes in the making. For example, passwords to extarnal services usually tag allong when dumping a production database, making it trying to log into the services exacly the same way. If there&#039;s no immediate ip blocking, it will succeed.&lt;/p&gt;

&lt;h3&gt;Customize that settings file&lt;/h3&gt;

&lt;p&gt;The settings file has a well-known powerful way of defining variable overrides for any settings variable. With setting $conf[&#039;myvar&#039;], all calls to variable_get(&#039;myvar&#039;) will fetch that variable instead of the default one or the one in db. To get an overview of what power that holds, just search for &#039;variable_set(&#039; in your IDE for a given module / tree structure on your site. Here are some examples of fixable things:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;When local environment is not set up as secure, the securepages module will redirect to prod when going to secure.&lt;/li&gt;
	&lt;li&gt;Error level on production are often set to 0 (no error display).&lt;/li&gt;
	&lt;li&gt;We most often don&#039;t need any cache on local environments, but always on production.&lt;/li&gt;
	&lt;li&gt;The same goes for page, css &amp;amp; js compression&lt;/li&gt;
	&lt;li&gt;There might be different temporary folder setups for production server.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;code&gt;$conf[&#039;securepages_enable&#039;] = 0;&lt;br /&gt;
$conf[&#039;https&#039;] = FALSE;&lt;br /&gt;
$conf[&#039;error_level&#039;] = ERROR_REPORTING_DISPLAY_ALL;&lt;br /&gt;
$conf[&#039;cache&#039;] = 0;&lt;br /&gt;
$conf[&#039;preprocess_css&#039;] = 0;&lt;br /&gt;
$conf[&#039;preprocess_js&#039;] = 0;$conf[&#039;site_name&#039;] = &quot;Mysite LOCAL&quot;;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add this to local settings file, and problems solved.&lt;/p&gt;

&lt;p&gt;PS: In Drupal 8, we will have settings files where every setting is available as files deployable using git. That&#039;s a definitive step forward in awesomeness. See &lt;a href=&quot;http://heyrocker.com/how-use-drupal-8-configuration-system&quot; title=&quot;this article&quot;&gt;this article&lt;/a&gt; for more information. However, in Drupal 8, this approach will still work as a master override.&lt;/p&gt;

&lt;h3&gt;Handle those test emails&lt;/h3&gt;

&lt;p&gt;Some prefer to have dev emails sent to gmail for max emulation of live site, and some just use the local mailbox. Either way, it is useful to direct all emails to the same email, ignoring the original reciepent. The module reroute_emails is great for that. It basically has 2 settings, enable and destination mail. If enabled, adding this to $conf will setup the redirect:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$conf[&#039;reroute_email_enable&#039;] = 1;&lt;br /&gt;
$conf[&#039;reroute_email_enable_message&#039;] = 0;&lt;br /&gt;
$conf[&#039;reroute_email_address&#039;] = &#039;test@localhost.com&#039;;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;..and rerouting is magically working.&lt;/p&gt;

&lt;h3&gt;Add that environment variable&lt;/h3&gt;

&lt;p&gt;To make this as painless as possible for new devs, you can keep these settings laying around in git. Using a separate file, like local.settings.php you can:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;Make a small modification to the settings.php&lt;/li&gt;
	&lt;li&gt;Include the file local.settings.php&lt;/li&gt;
	&lt;li&gt;Add any differentiating settings to this new file&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;If you want, force a siteload fail&lt;/em&gt; if environment variable is not set. We do not want prod to ever quietly think it&#039;s dev.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Let&#039;s say we have 3 different environments:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Local -&amp;gt; &#039;loc&#039; - Streamlined for low performance&lt;/li&gt;
	&lt;li&gt;Staging -&amp;gt; &#039;stage&#039; - Some integrations live&lt;/li&gt;
	&lt;li&gt;Production -&amp;gt; &#039;prod&#039; - All integrations live&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;We add 3 lines to settings.php. These lines are &lt;a href=&quot;http://drupal.org/node/1118520&quot; title=&quot;automatically added&quot;&gt;automatically added&lt;/a&gt; in Drupal 8, but we still need them in 7.x.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if (file_exists(DRUPAL_ROOT . &#039;/&#039; . $conf_path . &#039;/local.settings.php&#039;))&lt;br /&gt;
{ include DRUPAL_ROOT . &#039;/&#039; . $conf_path . &#039;/local.settings.php&#039;; }&lt;/code&gt;&lt;br /&gt;
 &lt;/p&gt;

&lt;p&gt;And then we add something like this in our local.settings.php:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;?php switch ($conf[&#039;environment&#039;]) {&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;  case &quot;prod&quot;:&lt;br /&gt;
    // Any special production-only cases&lt;br /&gt;
    break;&lt;br /&gt;
  case &quot;stage&quot;:&lt;br /&gt;
    $conf[&#039;cache&#039;] = 0;&lt;br /&gt;
    $conf[&#039;preprocess_css&#039;] = 0;&lt;br /&gt;
    $conf[&#039;preprocess_js&#039;] = 0;&lt;br /&gt;
  case &quot;dev&quot; :&lt;br /&gt;
  default:&lt;br /&gt;
    $conf[&#039;securepages_enable&#039;] = 0;&lt;br /&gt;
    $conf[&#039;https&#039;] = FALSE;&lt;br /&gt;
    $conf[&#039;error_level&#039;] = ERROR_REPORTING_DISPLAY_ALL;&lt;br /&gt;
    $conf[&#039;cache&#039;] = 0;&lt;br /&gt;
    $conf[&#039;preprocess_css&#039;] = 0;&lt;br /&gt;
    $conf[&#039;preprocess_js&#039;] = 0;&lt;br /&gt;
    $conf[&#039;site_name&#039;] = &quot;Mysite LOCAL&quot;;&lt;br /&gt;
    break;&lt;br /&gt;
};?&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When anything new is needed, add here &amp;amp; commit to git, and everybody&#039;s set to go.&lt;/p&gt;

&lt;h3&gt;Disabling / enabling those modules&lt;/h3&gt;

&lt;p&gt;Enabling and disabling devel and testing modules can be a pain, but automating the process is not a very big hassle. Usually we make a custom module for each site to hold custom code not fitting in anywhere else. Adding the following will handle any enabling / disabling of modules based on the environment variable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function hook_init(){&lt;br /&gt;
  // If we&#039;re on local, enable devel.&lt;br /&gt;
  if (variable_get(&#039;environment&#039;, &#039;loc&#039;) == &#039;loc&#039; &amp;amp;&amp;amp; !module_exists(&#039;devel&#039;)) {&lt;br /&gt;
    module_enable(array(&#039;devel&#039;));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Managing that ruleset with environments in mind&lt;/h3&gt;

&lt;p&gt;Almost all medium complex Drupal 7 sites rely on &lt;a href=&quot;http://drupal.org/project/rules&quot; title=&quot;Rules&quot;&gt;Rules&lt;/a&gt; at some level to manage both automated and manually triggered processes. The rules should be built with the same approach in mind.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Keep critical things from running wild on local&lt;/li&gt;
	&lt;li&gt;Try to emulate behavior locally&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;We talked about the $conf[&#039;environment&#039;] variable. We can drag this variable into rules.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Expose as a global token&lt;/li&gt;
	&lt;li&gt;Create a rule checker&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;By having it exposed, we can approach rules creation with development in mind, making it easier for ourselves at the time when the site is on production and new stuff is launched.&lt;/p&gt;

&lt;p&gt;With this, we can create separate rulesets for stage and prod, which enables us to fire events differently when on local or stage. For example, on commerce sites, we can have two different payment solutions, one for development (test) and one for production (live).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Bottom line&lt;/h3&gt;

&lt;p&gt;This is some approaches for making the migration between environments easier. The settings file, together with rules and eventual extra code can make the development process easier, both in terms of security and efficiency. Making all envs work out of the box is like an ultimate utopia, and with these steps you can reach a bit closer.  Happy env hacking!&lt;/p&gt;
</description>
 <guid isPermaLink="false">Node-78</guid>
 <pubDate>Tue, 20 Nov 2012 10:58:15 +0100</pubDate>
 <source url="https://admin.frontmag.no/tag/planetdrupal/rss">Frontmag</source>
</item>
</channel>
</rss>
