Answers.Body: <p><strong>Reinstalling the plugin after a database update</strong> just solved the problem : the database i sync'ed with didn't have the plugin installed (as it is still in development) </p>
  
  <p>Sorry for that one... :)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-13T07:49:56.673Z
Answers.LastActivityDate: 2015-10-13T07:49:56.673Z
Answers.UserDisplayName: zipang
Body: <p>So i've got this little plugin named AnnuaireAdherents with a variable that i try to access from within a template : 
  <code>
  annuaireadherents/
  ├── AnnuaireAdherentsPlugin.php
  ├── services
  │   ├── AnnuaireAdherents_Service.php
  │   └── Proxy.php
  ├── twigextensions
  │   └── AnnuaireAdherentsTwigExtension.php
  └── variables
      └── AnnuaireAdherentsVariable.php
  </code></p>
  
  <p>The variable should return a dynamic array, but let's try a static one first :</p>
  
  <pre><code>&lt;?php namespace Craft;
  
  /**
   * Variables provides access to list of adherents inside templates
   */
  class AnnuaireAdherentsVariable {
  
      /**
       * Liste d'adhérents
       *
       * @return array
       */
      public function adherents() {
          return array(
              array(
                  "raison_sociale" =&gt; "JOHN DOE &amp; Co",
                  "contact" =&gt; "JOHN DOE",
                  "cp" =&gt; "99999",
                  "address1" =&gt; "DESTINY STREET",
                  "locality" =&gt; "NOWHERE",
                  "mail" = "john.doe@nowhere.net"
              )
          );
      }
  }
  </code></pre>
  
  <p>I've tried every namespace variants i could think of to access it inside a template : </p>
  
  <pre><code>{% for adh in craft.annuaireAdherents.adherents %}
      {{ adh.raison_sociale }}
  {% endfor %}
  </code></pre>
  
  <p>but i keep receiving the error :</p>
  
  <blockquote>
    <p>Method "annuaireAdherents" for object "Craft\CraftVariable" does not exist </p>
  </blockquote>
  
  <p>Is it the correct namespace ?
  Do i have to relaunch Apache and Craft between each code modification to retest my variable ?
  Could there be another error that is masking me the true cause of this message ?</p>
  
  <p>Thanks a lot for any clue /  direction to investigate.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-12T23:00:49.950Z
Comments.Text: Sorry to ask, but did you install your plugin in Settings/Plugins?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-13T07:43:29.970Z
Comments.Text: Don't be sorry to ask : it was the main cause !
  
  I have to sync with the craft database updated by my coworker, and by doing that, i totally forgot that my plugin would be uninstalled as he doesn't have the plugin yet !!
  
  Thanks a lot for that silly one ! My apologies ! :)
Comments.UserDisplayName: zipang
Tags: <plugin-development><templating><variable>
Title: Can't access plugin variable in a twig template?
ThreadText: # Can't access plugin variable in a twig template?
  
  (Asked by: username_0 on 2015-10-12)
  
  So i've got this little plugin named AnnuaireAdherents with a variable that i try to access from within a template :
  `annuaireadherents/
  ├── AnnuaireAdherentsPlugin.php
  ├── services
  │   ├── AnnuaireAdherents_Service.php
  │   └── Proxy.php
  ├── twigextensions
  │   └── AnnuaireAdherentsTwigExtension.php
  └── variables
  └── AnnuaireAdherentsVariable.php`
  
  The variable should return a dynamic array, but let's try a static one first :
  
  ```
  <?php namespace Craft;
  
  /**
   * Variables provides access to list of adherents inside templates
   */
  class AnnuaireAdherentsVariable {
  
      /**
       * Liste d'adhérents
       *
       * @return array
       */
      public function adherents() {
          return array(
              array(
                  "raison_sociale" => "JOHN DOE & Co",
                  "contact" => "JOHN DOE",
                  "cp" => "99999",
                  "address1" => "DESTINY STREET",
                  "locality" => "NOWHERE",
                  "mail" = "john.doe@nowhere.net"
              )
          );
      }
  }
  
  ```
  
  I've tried every namespace variants i could think of to access it inside a template :
  
  ```
  {% for adh in craft.annuaireAdherents.adherents %}
      {{ adh.raison_sociale }}
  {% endfor %}
  
  ```
  
  but i keep receiving the error :
  
  > Method "annuaireAdherents" for object "Craft\CraftVariable" does not exist
  
  Is it the correct namespace ?
  Do i have to relaunch Apache and Craft between each code modification to retest my variable ?
  Could there be another error that is masking me the true cause of this message ?
  
  Thanks a lot for any clue / direction to investigate.
  
  **Tags:** plugin-development, templating, variable
  
  > **Comments:**
  > **username_1**: Sorry to ask, but did you install your plugin in Settings/Plugins?  
  > **username_0**: Don't be sorry to ask : it was the main cause !  I have to sync with the craft database updated by my coworker, and by doing that, i totally forgot that my plugin would be uninstalled as he doesn't have the plugin yet !!  Thanks a lot for that silly one ! My apologies ! :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-10-13. Score: 3
  
  **Reinstalling the plugin after a database update** just solved the problem : the database i sync'ed with didn't have the plugin installed (as it is still in development)
  
  Sorry for that one... :)
  
  
  ---
  
  