Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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.7k
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
  • 11.4k
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
  • 11.4k
4 votes

How can I use google recaptcha in my custom page?

First read carefully in which files the SO answer that you quoted tells you to put the code. Also, the code you attached is no longer working in Joomla 3.5. This is due to a change in the reCaptcha ...
ilias's user avatar
  • 725
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

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,936
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
  • 11.4k
3 votes

Getting wrong IP address from JFactory::getApplication()->input->server->get('REMOTE_ADDR','');

Maybe bad form to answer my own post, but I did locate the answer once I moved beyond the Joomla documentation. In my situation, the following line: $clientip = JFactory::getApplication()->input-...
Tim's user avatar
  • 61
3 votes
Accepted

Passing variables between a PHP module and a PHP script

You shouldn't use using $_SESSION with Joomla, but instead JFactory::getSession(). Try the following: Module: $session = JFactory::getSession(); $session->set('favcolor', 'green'); PHP file: $...
Lodder's user avatar
  • 26.9k
3 votes
Accepted

How to detect whether the user is on a specific menu?

You can use the following to display the desired message: $app = JFactory::getApplication(); exist $menu = $app->getMenu(); $title = $menu->getActive()->title; echo 'Welcome to ' . $...
Lodder's user avatar
  • 26.9k
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

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,801
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,801
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
  • 3,947
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
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

Joomla 3.6.2 won't save HTML Tags

It is because you have not set the text-filtering to "no filtering". Go to Global Configuration -> Text Filter : set the filtering for the desired type of user to "No-filtering".
Pratyush's user avatar
  • 496
2 votes
Accepted

Joomla 3x ,articles anywhere plugin ,not loading my article inside a module

Under the "Options" tab for both Custom modules, set "Prepare Content" to "Yes."
Michael Yaeger's user avatar
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,299
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
  • 11.4k
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
  • 11.4k
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.7k
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
  • 11.4k
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

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