Active
Project:
Journal Crunch
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
28 Jan 2011 at 12:56 UTC
Updated:
13 May 2011 at 03:22 UTC
Error message
Notice: Undefined variable: default in include() (line 3 of /var/www/vhosts/mysite.com/httpdocs/sites/all/themes/journalcrunch/node.tpl.php).
Fresh Drupal 7 install basic node page with no further blocks running anything and no 3rd party modules running.
Comments
Comment #1
pcforum12 commentedI get the following also:
Notice: Undefined variable: default in include() (line 3 of /var/www/virtual/myweb.com/sites/all/themes/journalcrunch/node.tpl.php).
At the top of Administration pages with new edited pages.
http://myweb.com/node/2
Inputting new articles displays the error twice as does clicking "read more" link.
A refresh of the page (F5 for example) removes the error.
The error returns when the page has been directed from a hyperlink in any other page.
Comment #2
drupalbaby commentedI confirm that problem on refresh: When you refresh the page with the error output it disappears but then when you go back to the other page and click read more it comes back.
Comment #3
drupalbaby commented3rd line causing error
if (!variable_get('isFirstNoStickyNode', $default)){
Comment #4
ckopack commentedgetting the same error. If I comment out the line in /journalcrunch/node.tpl.php my page completely disappears.
Comment #5
ckopack commentedchange:
if (!variable_get('isFirstNoStickyNode', $default)){
to:
if (!variable_get('isFirstNoStickyNode', '$default')){
just needs 'on_either_side_of_the_vaiable'
fixed for me! :)
Comment #6
drupalbaby commentedThat definitely fixed the problem! Thnaks bro
Comment #7
ckopack commentedNo worries mang. Glad I could actually contribute something.
Comment #8
pcforum12 commentedFix confirmed successful.
Thank you ckopack.
Comment #9
jogjayr commentedActually, IMHO, it should be changed to:
if (!variable_get('isFirstNoStickyNode', $default=NULL))
I don't know anything about Drupal, and not much about PHP, but the function signature has changed a little bit in Drupal 7.
See: http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/variab...
for reference...
I don't actually know if there is any difference between what I've suggested, and the solution suggested by ckopack but mine also works for me...
Comment #10
hosiya commentedI changed it to if (!variable_get('isFirstNoStickyNode', $default=NULL)) and i replaced my .htacces file from a drupal 6 to my new drupal 7 site, and everything is working great!
Comment #11
skounis commentedjogjayr's fix committed to HEAD
http://drupal.org/cvs?commit=496906
Comment #12
skounis commentedfix commited to 7.x-1.x Branch too
http://drupal.org/cvs?commit=496908
Comment #13
skounis commentedComment #14
skounis commentedgtsopour, can you please verify this fix?
Comment #15
gtsopour commentedok verified.
Comment #16
ckopack commentedvunderful! I love this community.
Comment #17
gaco commentedActually, that is NOT a solution.
In PHP, you can assign default values for missing arguments for a function. In the case of the 'variable_get' function, it can be called either using just the variable name:
variable_get('myVariable')or passing a default value, to be returned, in case the requested variable is not defined:variable_get('myVariable','myDefaultValue').jogjayr's code, is equivalent to calling the function, without the second parameter (it will assign null to the $default variable, before calling the function. Which is what the documentation says will happen if the second parameter is missing.
Since the original problem was that the $default variable was not defined in the first place, we can actually change the code from:
if (!variable_get('isFirstNoStickyNode', $default))to
if (!variable_get('isFirstNoStickyNode'))