4 Replies - 1295 Views - Last Post: 17 September 2014 - 07:33 AM Rate Topic: -----

#1 oceanicsky   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-September 14

HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 17 September 2014 - 03:07 AM

I am a beiginer in php and joomla template
i worked with my joomla template and suddenly my first page language changed to machine lang.
i got this error
Notice: Undefined index: view in C:\wamp\www\pixel\components\com_content\router.php on line 59
this is my 59 line code:
// are we dealing with an article or category that is attached to a menu item?
if (($menuItem instanceof stdClass) && $menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == (int) $query['id'])
{

what should i do to resolve it ?

Is This A Good Question/Topic? 0
  • +

Replies To: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 17 September 2014 - 03:10 AM

Use isset(), just like it is used elsewhere in the same statement, only for the view array index:

if (($menuItem instanceof stdClass) && isset($query['view']) && $menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == (int) $query['id'])

Was This Post Helpful? 0
  • +
  • -

#3 oceanicsky   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-September 14

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 17 September 2014 - 03:19 AM

thank you very much for your help
i exactly copy and paste the code you mentioned but the problem still exist :(
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3786
  • View blog
  • Posts: 13,715
  • Joined: 08-August 08

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 17 September 2014 - 05:56 AM

Don't be a copy/paste programmer! Think about where and why you're using isset() and where and why you might use it elsewhere.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,527
  • Joined: 12-December 12

Re: HOW TO REMOVE NOTICE "UNDEFINED INDEX" ?

Posted 17 September 2014 - 07:33 AM

Copy and paste programming :wiki
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1