Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract variables into template with global scope
    primarykey
    data
    text
    <p>I want to extract all variables assigned in my controller into my template using the extract() function. An simple example is this:</p> <pre><code> private function render() { extract($this-&gt;controller_vars); require_once("layout.php"); } </code></pre> <p>The problem is that within my layout.php I am making calls to other methods which "includes" files but more importantly displays the correct action/view within the layout.</p> <pre><code> // This method is called where I want to display the "content" page: public function display_action() { require_once("selected_action.php"); } </code></pre> <p>So I effectively have access to the extracted variables inside of layout.php, but my view/actions don't because they are included through a method in the same controller.</p> <p>Is there a workaround where I can give the extracted variables global access or perhaps another solution for my problem?</p> <p><strong>ADDITIONAL INFORMATION:</strong></p> <p>The code above is 2 "watered down" versions of the methods in my view class</p> <pre><code> class views { private function render() { extract($this-&gt;controller_vars); require_once("layout.php"); } public function display_action() { require_once("selected_action.php"); } } </code></pre> <p>In the layout.php file I would then make a call such as:</p> <pre><code> &lt;div id="content_area"&gt; $this-&gt;display_action(); &lt;/div&gt; </code></pre> <p><strong>MORE MORE MORE</strong></p> <p>I do have access to these variables at the moment by an array property in my view class called $this->controller_vars, so if I assigned a list of users it would be stored in $this->controller_vars['users']; I am just looking for a way to extract it so that I can have access to them with a simple $users as appose to $this->controller_vars['users']</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload