Continue shopping button bahaviour


I saw many posts regarding “continue shopping” button. But unfortunately could not find the right answer.

The matter is that from cart (checkout) page if you have some products it redirects you to the last visited category, which is well thought and absolutely perfect.

If you do not have any products it redirects you to index page which is also logic!

But from the product pop up window the same button does nothing, that does not make any sence and give an impression for the clients that the system is frozen.

If I change the link in product_notification.tpl and make it same as in cart_content.tpl

{include file="buttons/continue_shopping.tpl" but_href=$continue_url|default:$index_script}

it bring me to index page… but the same code from checkout page bring you to the last category

My question is how to reach the same behaviour and get last category from popup “continue shopping” button.