0

I am trying to put a module inside another component. According to https://www.joomlashack.com/blog/joomla-how-to/module-position-component/ I can put

<?php echo JHtml::_('content.prepare', '{loadposition myposition}'); ?>

in the PHP file in question.

I've tried this but it didn't work for me, this line of code simply doesn't output anything to my HTML. There is no error thrown either. So is this still technique still available? Or did I miss anything?

1
  • How can we progress this page so that it is not bumped by the system? Do you need a different/better answer? Do you want to edit your question to specify what you need?
    – mickmackusa
    Jun 21 at 7:47
0

I tried this before too. But there is no need to do a content.prepare because we can simply create a module position instead.

// Load the namespacing for Factory (the new way instead of JFactory)
use Joomla\CMS\Factory;

// Load the module position
<?php echo Factory::getApplication()->getDocument()->loadRenderer('modules')->render("logo"); ?>

In this instance the module position will be called "logo" but you can call it anything you want. In one case I used a subform to dynamically create module positions on the fly within another module.

0

@Eoin's snippet works perfectly other than it should be JFactory.

// Load the namespacing for Factory (the new way instead of JFactory)
use Joomla\CMS\Factory;

// Load the module position
<?php echo JFactory::getApplication()->getDocument()->loadRenderer('modules')->render("logo"); ?>
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.