You got a logical error here:
$this->referer(null, true) // true as second param: only internal
will only return the lightview layout if
- there is a referer (not always the case)
- internal referrer
So this is probably not what you want.
You cannot do that this easily. Sometimes there is just no referrer. And even if there is you might still don't know if this person came from somewhere else and just "hid" the referrer. Or then browsed your site (creating internal referrers from here on).
You would need to store the initial result on first visit in the session to check against later on. But even so your approach is highly inconsistent and very likely breakable...