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 ...
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">
...
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 ...
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 ...
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() &...
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 ...
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 ' . $...
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-...
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:
$...
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 ...
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 ...
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 ...
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 ...
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 = ...
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 ...
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 ...
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->...
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 ...
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 ...
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 ...
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
<...
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-&...
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 ...
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".
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."
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 ...
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 ...
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()-...
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($...
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. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
custom-module × 103joomla-3.x × 38
module × 23
php × 15
custom-component × 11
module-params × 8
css × 7
development × 6
articles × 6
joomla-4.x × 6
plugin × 4
javascript × 4
custom-field × 4
ajax × 4
installation × 4
module-display × 4
xml × 4
templates × 3
extensions × 3
user × 3
administrator × 3
menu-item × 3
jdatabase × 3
joomla-3.5 × 3
emails × 3