Answers.Body: <p>Ok, this is what I get for trying to be clever (lazy)... </p>
  
  <p>I've always begrudged typing in '<strong>craft</strong>.myPlugin...' every time I wanted refer to my plugin, so I set a Route Variable in my plugin like so:</p>
  
  <pre><code>  craft()-&gt;urlManager-&gt;setRouteVariables(
      array(
        'myPlugin' =&gt; craft()-&gt;myPlugin, 
      )
    );
  </code></pre>
  
  <p>It would appear none of my route variables work in the 404 template. That in itself is a bit odd, so to accomodate my laziness I've added this to the top of my 404 code:</p>
  
  <pre><code>{% set myPlugin = craft.myPlugin %}
  </code></pre>
  
  <p>It would be interesting to know if this choice has any detrimental effects? <em>(besides being looked down upon by my peers)</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-06T09:09:17.910Z
Answers.Text: I just found this discussion: http://craftcms.stackexchange.com/questions/4161/do-404s-get-access-to-variables-set-with-setroutevariables
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-06T09:09:42.617Z
Answers.Text: Alternative idea: expose your plugin variables as [Twig globals](http://twig.sensiolabs.org/doc/advanced.html#globals).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-06T08:35:10.033Z
Answers.LastActivityDate: 2015-10-06T08:35:10.033Z
Answers.UserDisplayName: Mark Notton
Answers.Body: <p>If you want to make a new variable available globally, you should do it by registering a new Twig extension, using the <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#addTwigExtension" rel="nofollow">addTwigExtension</a> hook. You can use the Twig extension’s <a href="http://twig.sensiolabs.org/api/master/Twig_Extension.html#method_getGlobals" rel="nofollow">getGlobals()</a> method to create whatever new global variables you want.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-06T16:26:43.340Z
Answers.LastActivityDate: 2015-10-06T16:26:43.340Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Before I go into detail and share my error logs and plugin details, I'll ask the simple question first:</p>
  
  <p><strong>When testing my 404 page, no plugin functionality works. Is this intentional?</strong> </p>
  
  <p>Just for testing purposes, I tried to include the index template file in my 404 template:</p>
  
  <pre><code>{% include 'index' %}
  </code></pre>
  
  <p>This pulls in the homepage fine, but still causes an error: </p>
  
  <blockquote>
    <p>Variable "pluginName" does not exist in "404"...</p>
  </blockquote>
  
  <p>The following returns 'yes' when legitmately on the homepage, and 'no' when on a 404 page, which uses the <em>include</em> I just mentioned. </p>
  
  <pre><code>{{ pluginName is defined ? 'yes' : 'no'}}
  </code></pre>
  
  <p>Any insight would be great. </p>
  
  <p>Mark</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-06T07:06:41.500Z
Comments.Text: There should not be any difference and your plugin / plugin variables should work on 404 just like on any other template. Does Twig / Craft work at all?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-06T08:21:05.930Z
Comments.Text: That's the weird thing. Craft/Twig functions work perfectly. {{ craft.request.getLastSegment() }} for example is fine. I'm going to give my plugin the once-over to see if there are any obvious issues.
Comments.UserDisplayName: Mark Notton
Tags: <plugin-development><404>
Title: Plugin does not exist on 404 page?
ThreadText: # Plugin does not exist on 404 page?
  
  (Asked by: username_0 on 2015-10-06)
  
  Before I go into detail and share my error logs and plugin details, I'll ask the simple question first:
  
  **When testing my 404 page, no plugin functionality works. Is this intentional?**
  
  Just for testing purposes, I tried to include the index template file in my 404 template:
  
  ```
  {% include 'index' %}
  
  ```
  
  This pulls in the homepage fine, but still causes an error:
  
  > Variable "pluginName" does not exist in "404"...
  
  The following returns 'yes' when legitmately on the homepage, and 'no' when on a 404 page, which uses the *include* I just mentioned.
  
  ```
  {{ pluginName is defined ? 'yes' : 'no'}}
  
  ```
  
  Any insight would be great.
  
  Mark
  
  **Tags:** plugin-development, 404
  
  > **Comments:**
  > **username_1**: There should not be any difference and your plugin / plugin variables should work on 404 just like on any other template. Does Twig / Craft work at all?  
  > **username_0**: That's the weird thing. Craft/Twig functions work perfectly. {{ craft.request.getLastSegment() }} for example is fine. I'm going to give my plugin the once-over to see if there are any obvious issues.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-10-06. Score: 2 | Accepted answer
  
  Ok, this is what I get for trying to be clever (lazy)...
  
  I've always begrudged typing in '**craft**.myPlugin...' every time I wanted refer to my plugin, so I set a Route Variable in my plugin like so:
  
  ```
    craft()->urlManager->setRouteVariables(
      array(
        'myPlugin' => craft()->myPlugin, 
      )
    );
  
  ```
  
  It would appear none of my route variables work in the 404 template. That in itself is a bit odd, so to accomodate my laziness I've added this to the top of my 404 code:
  
  ```
  {% set myPlugin = craft.myPlugin %}
  
  ```
  
  It would be interesting to know if this choice has any detrimental effects? *(besides being looked down upon by my peers)*
  
  > **Comments:**
  > **username_1**: I just found this discussion: http://craftcms.stackexchange.com/questions/4161/do-404s-get-access-to-variables-set-with-setroutevariables  
  > **username_1**: Alternative idea: expose your plugin variables as [Twig globals](http://twig.sensiolabs.org/doc/advanced.html#globals).  
  
  ---
  
  ### Answer by username_2 on 2015-10-06. Score: 2
  
  If you want to make a new variable available globally, you should do it by registering a new Twig extension, using the [addTwigExtension](http://buildwithcraft.com/docs/plugins/hooks-reference#addTwigExtension) hook. You can use the Twig extension’s [getGlobals()](http://twig.sensiolabs.org/api/master/Twig_Extension.html#method_getGlobals) method to create whatever new global variables you want.
  
  
  ---
  
  