Search
Other Modules Anywhere questions
Forum

Modules anywhere within source

Peter Tuson's Avatar Peter Tuson
Hello Peter,

Sorry to ask you this but I have almost finished updating the first site to Joomla 4 ready for testing. I just need the modals sorted out and I was trying to use bootstrap for now.

That involves adding some php to custom modules which I use sourcerer for. However some of my existing modals incorporate modules anywhere so I was trying, unsuccessfully, to incorporated the modules within sourcerer. Is this possible at all and if so how?

I would prefer your approach to modals but it seems that there will still be some time before you have it ready for Joomla 4.

Regards,

Peter.
Peter van Westen's Avatar Peter van Westen ADMIN
I am not sure what your question or issue is...

Can you give an example of how you are using Sourcerer and how you want to use Modules Anywhere in that?
Please post a rating at the Joomla! Extensions Directory
Peter Tuson's Avatar Peter Tuson
Peter,

Here is a section of the code:
span style="color: #0000cc;">$body = '';</span></span> <span style="font-family: monospace; color: #555555;"><span style="color: #0000cc;"><span style="color: #0000cc;"><img src="/iShine/media/sourcerer/images/tab.svg" alt="" />$options = array();<br /><img src="/iShine/media/sourcerer/images/tab.svg" alt="" />$options['width'] = '10rem';<br /><img src="/iShine/media/sourcerer/images/tab.svg" alt="" />$options['title'] = 'My Account';<br /><img src="/iShine/media/sourcerer/images/tab.svg" alt="" />echo JHTML::_('bootstrap.renderModal', 'whatifModal', $options, $body);</span><span style="font-family: monospace; color: #555555;"></span><br />?&gt;</span><br /> {/source}</span></div>

I am trying to put the modal where the $body is, just prior to that is a bootstrap modal that works. I originally put it as $body = '{module title="whatifmodule"}' at the top of the script but that produced an error complaining of the {.

Regards,

Peter.
Peter van Westen's Avatar Peter van Westen ADMIN
So for readability, this is your code (the HTML is pretty useless):
{source}
$body = '{module title="whatifmodule"}'; 
$options = array();
$options = '10rem';
$options = 'My Account';
echo JHTML::_('bootstrap.renderModal', 'whatifModal', $options, $body);?>
{/source}

So no, you can't just put the {module} tag in there. That will get replaced with full HTML code, that will break either the PHP code, or the javascript code the bootstrap thing renders.

Either place the module in a div, then see if you can make a modal open that div (by id/class).
Or make the modal open a URL, that opens a Joomla article. Then place your {module} tag in that article.
Please post a rating at the Joomla! Extensions Directory
Peter Tuson's Avatar Peter Tuson
Hello Peter,

Thanks for your help.

I decided to copy the resulting code that bootstrap produced and then add the modules anywhere directly to the body, for example:

<div id="whatifModal" class="joomla-modal modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title color">What if ?</h3>
<button type="button" class="btn-close novalidate" data-bs-dismiss="modal" aria-label="Close"></button></div>
<div class="modal-body">{module title="Career - What if"}</div>
</div>
</div>
</div>

Then I used the standard link to it, for example:

<li><a id="myaccount" style="cursor: pointer;" data-bs-target="#myAccountModal" data-bs-toggle="modal"><img src="images/iShine/Menu/my_account.svg" alt="My Account" style="width: 8%; margin-left: -0.3rem;" /><span class="color" style="margin-left: 0.7rem;">My Account</span></a></li>

This turned out to be very easy to implement and it works well.

Regards,

Peter.
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great! 🙂👍
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription