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

pcforum12’s picture

I 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.

drupalbaby’s picture

I 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.

drupalbaby’s picture

3rd line causing error
if (!variable_get('isFirstNoStickyNode', $default)){

ckopack’s picture

getting the same error. If I comment out the line in /journalcrunch/node.tpl.php my page completely disappears.

ckopack’s picture

change:

if (!variable_get('isFirstNoStickyNode', $default)){

to:

if (!variable_get('isFirstNoStickyNode', '$default')){

just needs 'on_either_side_of_the_vaiable'

fixed for me! :)

drupalbaby’s picture

That definitely fixed the problem! Thnaks bro

ckopack’s picture

No worries mang. Glad I could actually contribute something.

pcforum12’s picture

Fix confirmed successful.

Thank you ckopack.

jogjayr’s picture

Actually, 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...

hosiya’s picture

I 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!

skounis’s picture

jogjayr's fix committed to HEAD
http://drupal.org/cvs?commit=496906

skounis’s picture

fix commited to 7.x-1.x Branch too
http://drupal.org/cvs?commit=496908

skounis’s picture

Status: Active » Fixed
skounis’s picture

Assigned: Unassigned » gtsopour

gtsopour, can you please verify this fix?

gtsopour’s picture

Status: Fixed » Closed (fixed)

ok verified.

ckopack’s picture

vunderful! I love this community.

gaco’s picture

Status: Closed (fixed) » Active

Actually, 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'))