Fork me on GitHub

Hello my name is Pui, I am a web developer and web designer.

Expression Engine bug - PHP error Undefined variable: category_name in helpers/segment_helper.php

27 September 2014

On updating my site, I noticed one published article where there was a PHP error at the top of the page:
PHP error Undefined variable: category_name in helpers/segment_helper.php

I discovered that this was due to the fact that the page had a reserved category word in its URL.
The URL being: http://www.linglau.com/articles/view/multiple-category-naming-issues-in-expression-engine

In order to solve this, edit system/expressionengine/helpers/segment_helper.php around line 97 to add this conditional above ee()->load->model(‘category_model’); so it looks like:

if (empty($category_name)) { 
  return ''; 
}
ee()->load->model('category_model');


The bug is documented here.

About the author

Pui-Ling Lau, front end web developer and designer based in Kent and London

Pui is a User Experience developer working for Reading Room, a digital agency based in Central London.