Can a Joomla module “know” what position it's in?

后端 未结 5 1553
我寻月下人不归
我寻月下人不归 2021-01-06 19:00

I\'m fairly new to Joomla (I\'ve been more of a Wordpress guy) and I have a question about module positions.

Can a module know what position it\'s in. For instance

5条回答
  •  滥情空心
    2021-01-06 19:27

    I found the answer! Mostly thanks to @Hanny. His idea of using the modules id got me googling for that and I came across the answer. For anyone else that happens to be looking to do something similar here it is.

    You use a global variable $module (who'd a thought, right?)

    So my code now looks like this:

    $class = '';
    if($module->position == 'position1'){
         $class = 'class1';
    }
    and so on...
    

    Pretty simple, huh?

    To find out what else you can do with the global variable $module just put this in your code and see what info you can use:

    echo(print_r($module));
    

    Thanks for all your help!

提交回复
热议问题