Skip to main content
7 votes

What does "Prepare Content" do and when should it be used?

Prepare Content will enable the onContentPrepare plugins event for the content of the module. So the custom html module's html content will go through the process of content plugins, similar to what ...
FFrewin's user avatar
  • 19.8k
5 votes
Accepted

How to use HTMLHelper to add to the document head

1) JHtml is an alias for Joomla\CMS\HTML\HTMLHelper class. You'll have to start using the real class sooner or later because the alias will not exist in Joomla! 5.0. To use the real class you have to ...
Sharky's user avatar
  • 12k
5 votes
Accepted

How to create a custom script to force the download of a .csv file that is generated in real time?

If this needs to be done by the module (there's no accompanying component or the component is 3rd party and you can't touch it), use com_ajax. Point the form to com_ajax: <form method="post"> ...
Sharky's user avatar
  • 12k
4 votes

How to create a custom script to force the download of a .csv file that is generated in real time?

Regarding clearing the output buffer, some time ago I had a similar issue and this solved the issue, at least for me: // Close output buffers till the level reaches 0 while (ob_get_level() &...
n.h.'s user avatar
  • 871
4 votes

How to create a custom script to force the download of a .csv file that is generated in real time?

It turned out that using @n.h.'s nifty output buffer cleansing workaround was not necessary after implementing @Sharky's advice regarding com_ajax and getAjax(). So that researchers will be able to ...
mickmackusa's user avatar
  • 4,846
4 votes

Getting CSS style to vary with different module instances

I figured out my problems, so I thought I would answer my own question. 1) Different styling for different instances of the same module Don't forget Joomla has unique module ids! And there's an ...
William's user avatar
  • 299
4 votes

Migrating custom module to Joomla 4

Lodder's answer is fully valid, however he did not want to waste time to reformulate the query part of this old script in the question. As a morning drill during my coffee time I corrected that part ...
Zollie's user avatar
  • 2,956
3 votes
Accepted

Module Template/alternate layout Name language Override

The layout language key is built like this: $key = strtoupper($module . '_LAYOUT_' . $value); Where $module is the module name (including mod_ prefix) and $value is the layout name. Example string ...
Sharky's user avatar
  • 12k
3 votes

How to style a module or article title with font awesome icons?

You could add some custom CSS like this or similar: .page-class .page-header h1::before { font-family: FontAwesome; content: "\f095"; } Use a page class to target a specific page. You can ...
Neil Robertson's user avatar
3 votes
Accepted

Use addScriptOptions for multiple modules on same page

A simple code review: You don't need the condition block because getScriptOptions() always returns an array. getScriptOptions() documentation If you want to declare the variable $configs... $configs = ...
mickmackusa's user avatar
  • 4,846
3 votes

How to build a podcasting site?

A podcast is just another form of content in a file therefore yes you can and the second part of your idea is going to need some form or subscription/payment process. A quick Google and this article ...
Irata's user avatar
  • 4,361
3 votes

Show 'menuitem' field name in frontend of module

You can use the following: $menu = Joomla\CMS\Factory::getApplication()->getMenu(); $menuItem = $menu->getItem($menulink); echo $menuItem->title; If you var_dump($menuItem);, it will show ...
Lodder's user avatar
  • 26.9k
3 votes

Migrating custom module to Joomla 4

JRequest was deprecated in Joomla 2.5 (I think), so you can now use JInput, like so: use Joomla\CMS\Factory; $db = Factory::getDbo(); $input = Factory::getApplication()->input; $id = $input->...
Lodder's user avatar
  • 26.9k
3 votes
Accepted

What should I use to escape a module parameter in Joomla 5?

The proposed methods don't work simply because they don't exist. htmlspecialchars() is fine. There is no generic utility method because it would really just be a proxy to htmlspecialchars(). For ...
Sharky's user avatar
  • 12k
2 votes

Using AJAX in a custom module - how to do it?

I don't understand why you are trying to bypass the framework. I know it is resources wise but it opens you up to security risks. The other thing is that you can't use framework classes/functions as ...
Artur Stępień's user avatar
2 votes

XML file does not upload with my custom module

The manifest (main xml) is the only file that doesn't need to be included in the manifest (ie itself). Other xml files need to be listed either as files or be in listed folders. One attribute in the ...
jamesgarrett's user avatar
  • 3,339
2 votes

Style a custom HTML module

You don't have to add separate CSS file. You can just style-up new selectors you want, or use some existing in main template.css or custom.css, whichever you are using, and reference them in Custom ...
Mikan's user avatar
  • 3,007
2 votes
Accepted

Is it possible to add a new module position within a module?

Although using content plugin works, there is no need for it in PHP code. Instead you can use the document renderer directly: use Joomla\CMS\Factory; echo Factory::getApplication()->getDocument()-...
Sharky's user avatar
  • 12k
2 votes
Accepted

How can I display the first name of the currently logged in user in content

The code required to extract the first name of the currently logged in user is fairly simple. Here's an example: <?php $user = JFactory::getUser(); if (!$user->guest) { echo strtok($...
Neil Robertson's user avatar
2 votes
Accepted

Custom module best practices. JS inside template file or not?

Adding stylesheets, scripts and declaring php vars is all done inside the main mod_mygallery.php file This is bad. Styles and scripts should be added in layout files to allow overriding with ease. ...
Sharky's user avatar
  • 12k
2 votes
Accepted

Pass PHP variables to CSS?

Personally I wouldn't use a .css.php file. The following assumes you WON'T be supporting Internet Explorer and I will be answering your question about CSS filters. The grid/masonry can be asked as a ...
Lodder's user avatar
  • 26.9k
2 votes

What directory should contain GPL scripts from external source? Best practice?

If the external resource is just 1 file (even if it has a minified version with it), I would place it directly in the /assets/js directory. If the resource is a collection of 2 or more files, I would ...
Ricky Goldman's user avatar
2 votes
Accepted

How do I pass _JEXEC to a php file?

There is no way to pass the JEXEC constant to the file, other than including a file that defines it - Generally you would want to go through Joomla for this. Turn the whole form to a module and use ...
FFrewin's user avatar
  • 19.8k
2 votes
Accepted

Getting module parameters in AJAX call using module id

If you know the ID, you can use JModuleHelper::getModuleById(). https://api.joomla.org/cms-3/classes/Joomla.CMS.Helper.ModuleHelper.html#method_getModuleById
Sharky's user avatar
  • 12k
2 votes
Accepted

Joomla 4 - Module Backend Subform subform-row-add "row" not available

The way the event is invoked is slightly different for Joomla 4. You can use the following: $(document).on('subform-row-add', function(event) { console.log(event.detail.row); }); Or native ES6+ ...
Lodder's user avatar
  • 26.9k
2 votes
Accepted

Use Text-Editor in UIkit Modal (Module Backend)

I duplicated your scenario (using the TinyMCE editor which is the base of JCE editor too) and it looks like for me that the toggleEditor() function is "handling" this interesting behavior ...
Zollie's user avatar
  • 2,956
2 votes

Can a module used in an article have parameters?

No, it is not possible. Parameters are defined in the module instance with the given ID. You'd need a custom shortcode plugin to pass any parameters.
Sharky's user avatar
  • 12k
2 votes
Accepted

HTMLHelper call a custom class in a module

You need to register the HTML services with the service registry. If your component uses the same convention as Joomla core, then the services are registered during the boot up process of the ...
Sharky's user avatar
  • 12k
2 votes
Accepted

How to use component's joomla.asset.json file in module?

You have to use a relative path in your call to addRegistryFile, ie: $wr->addRegistryFile('media/com_foo/joomla.asset.json');
Robbie Jackson's user avatar
1 vote

Add Options to {loadedmoduleid ID}

Hmmm. You sure you need a module for that, and not a plugin? There's no mechanism in place to pass parameters from an article to a module, cleanly. They all center around the module getting the menu ...
Arlen's user avatar
  • 802

Only top scored, non community-wiki answers of a minimum length are eligible