{"id":2951,"date":"2014-03-11T18:01:08","date_gmt":"2014-03-11T18:01:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/11\/opencart-how-to-make-a-global-variable-collection-of-common-programming-errors-2\/"},"modified":"2014-03-11T18:01:08","modified_gmt":"2014-03-11T18:01:08","slug":"opencart-how-to-make-a-global-variable-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/11\/opencart-how-to-make-a-global-variable-collection-of-common-programming-errors-2\/","title":{"rendered":"OpenCart: How to make a global variable?-Collection of common programming errors"},"content":{"rendered":"<p>you can use <code>$GLOBALS<\/code> super global array<\/p>\n<p>for example declare it first in <code>controller\/common\/header.php<\/code><\/p>\n<pre><code>$GLOBALS[\"1\"] = \"test\";\n<\/code><\/pre>\n<p>then use it in any tpl file like<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>regarding that <code>header<\/code> thing, that <code>header<\/code> and <code>five other files<\/code> are actually declared in every controller file (corresponding to every tpl file ) like this<\/p>\n<pre><code>$this-&gt;children = array(\n            'common\/column_left',\n            'common\/column_right',\n            'common\/content_top',\n            'common\/content_bottom',\n            'common\/footer',\n            'common\/header'     \n        );\n<\/code><\/pre>\n<p><strong>Answer to updated question<\/strong><\/p>\n<p><strong>\/catalog\/controller\/common\/header.php<\/strong><\/p>\n<pre><code>\n\n\n\n\n\n\n\n    \n        \n            <\/code><\/pre>\n<ul class=\"slides\">\n<li><code><img decoding=\"async\" src=\"catalog\/view\/theme\/default\/image\/desktop.png\" \/><\/code><\/li>\n<li><code><img decoding=\"async\" src=\"catalog\/view\/theme\/default\/image\/blogger.png\" \/><\/code><\/li>\n<\/ul>\n<pre>\n        \n    \n\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>you can use $GLOBALS super global array for example declare it first in controller\/common\/header.php $GLOBALS[&#8220;1&#8221;] = &#8220;test&#8221;; then use it in any tpl file like regarding that header thing, that header and five other files are actually declared in every controller file (corresponding to every tpl file ) like this $this-&gt;children = array( &#8216;common\/column_left&#8217;, &#8216;common\/column_right&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2951","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2951"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2951\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}