{"id":452,"date":"2011-12-05T23:01:50","date_gmt":"2011-12-05T21:01:50","guid":{"rendered":"https:\/\/www.moonbug.org\/log\/?p=452"},"modified":"2011-12-14T19:40:41","modified_gmt":"2011-12-14T17:40:41","slug":"this-lang-fail","status":"publish","type":"post","link":"https:\/\/www.moonbug.org\/log\/2011\/12\/05\/this-lang-fail\/","title":{"rendered":"$this->lang \/* FAIL *\/"},"content":{"rendered":"<p>Note to self: when dealing with a multi-language site, in a <a href=\"http:\/\/codeigniter.com\/\">CodeIgniter<\/a> extended class constructor, do <strong>not<\/strong> attempt this:<\/p>\n<pre><code><br \/>\tprotected $lang;<br \/>\tfunction __construct() {<br \/>\t\tparent::__construct();<br \/>\t\t$this->lang = $this->uri->segment(1);<br \/>\t}<br \/><\/code><\/pre>\n<p>Instead you will want to do this:<\/p>\n<pre><code>\r\n\tprotected $language;\r\n\tfunction __construct() {\r\n\t\tparent::__construct();\r\n\t\t$this->language = $this->uri->segment(1);\r\n\t}\r\n<\/code><\/pre>\n<p>See what I did there? &#8216;lang&#8217; to &#8216;language&#8217;. <\/p>\n<p>As it happens <code>$this->lang<\/code>, when in a CI constructor, will name-conflict with any native CI system library that needs to tap into something similar to <code>$CI =& get_instance()<\/code>, with a subsequent <code>$CI->load-><b>lang<\/b>('some_library')<\/code> call.<\/p>\n<p>Thank me not.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note to self: when dealing with a multi-language site, in a CodeIgniter extended class constructor, do not attempt this: Instead you will want to do this: protected $language; function __construct() { parent::__construct(); $this->language = $this->uri->segment(1); } See what I did there? &#8216;lang&#8217; to &#8216;language&#8217;. As it happens $this->lang, when in a CI constructor, will name-conflict [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[28,29,6,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/posts\/452"}],"collection":[{"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":19,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/posts\/452\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moonbug.org\/log\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}