I am trying to program into my .phtml files an if statement if the guest is on a category list page, or on a product page.
For example this code:
=
While Alan's answer will work, there is a more direct option, and you were actually on the right track with your code snippet... you just need to inspect the controller name rather than the module name:
getFrontController()->getRequest()->getControllerName(); ?>
That will return category
or product
based on their controllers being CategoryController.php
and ProductController.php
respectively.
This does assume that you've not installed any third-party modules that rewrite those controllers with their own.