As of May 31, 2023, we have updated our Code of Conduct.
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.6k
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
  • 9,936
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
  • 9,936
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
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.8k
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.8k
3 votes
Accepted

Get user info and send email from button

Download Flexi Custom Code Module from the JED. Install the module and publish it to the position of your choice. Below the custom code box leave the option to use PHP on and disable the cleanup of ...
Terry Carter's user avatar
  • 1,777
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
  • 9,936
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,761
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,761
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,057
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.8k
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.8k
3 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,846
2 votes

Unable to insert form values in to database Joomla 3

Just a little to expand on @Sahil Purav's answer. The reason why your values might not be being stored as they should is because you need to define a filter in your inputs. Try adding RAW to all of ...
Lodder's user avatar
  • 26.8k
2 votes
Accepted

How can I display a system message from a custom HTML module

A common reason for plugins not working in Custom HTML modules is that they are not processed by Joomla Content plugins by default. In order to enable this, go to the Options tab in your Custom HTML ...
johanpw's user avatar
  • 13.3k
2 votes
Accepted

Calling module params from custom field type

You probably forgot to specify container of the form fields. Your code should be something like $this->form->getValue('fallBeginning', 'container') if your field has actual html code like <...
Marko D's user avatar
  • 471
2 votes
Accepted

Custom self-made module doesn't show content after J3.4.3 upgrade

The problem is that you try to get items from the contacts model but the result is probably empty. Notices helper.php line 54 // Category filter $model->setState('filter.category_id', $params-&...
fruppel's user avatar
  • 3,723
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,269
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
  • 9,936
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
  • 9,936

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