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

后端 未结 5 1519
我寻月下人不归
我寻月下人不归 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:25

    A module instance is assigned to a single position and this is stored in the database and normally you would style the position in the template. A module instance can only be assigned to one position. So while it's an interesting question, it's not really a practical one.

    The exceptions to this are the following: loadposition ... you might want to know if a module is being loaded using the plugin because this would put it potentially somewhere besides the styled area for the position. THough i would recommend always making a new instance for this precisely so you have more control.

    loadmodule ... module loaded by name using the plugin. In this case again you are probably better off making a new instance of the module and styling it. Also I'd put it in a span or div anyway, depending what it is.

    jdocinclude:module ... loading a module directly in a template. Again if you are doing this I would wrap it in a span or div. In this case you are also allowed to include a string of inline styles if you like that kind of thing.

    Rendering the module to a string and echoing it, again that is basically a very customized solution and you would want to set the styles and options.

提交回复
热议问题