toivo blog
web and other experiments
  • joomla
    • Accessing External Databases
    • Fetching User Custom Fields in Joomla 4
    • Updating articles by deleted authors
    • how to list users with custom fields
    • finding the origin of cryptic messages
    • careful with uninstall
    • adding time to logged-In users
    • troubleshooting smtp connection
    • gmail as smtp host in joomla
  • hiking
    • viking way part 1
    • viking way part 2
  1. You are here:  
  2. Home
  3. joomla

Accessing External Databases

Would you like to create a module to display some statistics from another Joomla site, hosted in the same server? That is perfectly possible and relatively simple, by using the Joomla database connection to an external database.

A proof of concept module, Databases, can be downloaded from https://extensions.talikka.com/downloads/databases/mod_databases-1.0.0.zip

 

Details
Written by: Toivo Talikka
Category: Joomla
Published: 01 September 2024
Hits: 12215

Fetching User Custom Fields in Joomla 4

This example displays three user custom fields, fielda, fieldb and fieldc.  It uses the PHP function array_column() and therefore it does not need a foreach loop.

use Joomla\CMS\Factory;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
$customFields = FieldsHelper::getFields('com_users.user', Factory::getUser(), true);
$values = array_column($customFields, 'value', 'name');
// echo 'values = ' . print_r($values, true);
echo 'fielda = ' . $values['fielda'] . ' fieldb = ' . $values['fieldb'] . ' fieldc = ' . $values['fieldc'];

Details
Written by: Toivo Talikka
Category: Joomla
Published: 08 January 2023
Hits: 23717

Finding the origin of cryptic messages

Sometimes websites produce warnings or error messages without giving any clues what caused the issue. Surely this has happened to everyone and it is annoying, especially if it happens at a website you are supposed to maintain. 

Recently someone reported that they are unable to update articles because every time they try they get the message "Warning, Registration failed. Please try again."  Clearly this message does not belong anywhere near the editing process where articles are updated or created. Something must have gone wrong in a third party extension or a home grown plugin.

If you have a similar situation where a seemingly unrelated error or a warning is reported in the browser, search for the text string from the website or clone or simply download the filesystem of the site and search on your workstation. A utility like grep or Windows grep are the easiest to use.

The text of the message is most likely to be found in one of the language files.  This of course assumes that the extension that produced the message follows Joomla best practice of keeping the message texts in separate files, consisting of language constants and language strings.

Language Files

Third party extensions add their own language files into the languages folder either at the front end or the back end of the site, or both.  Extensions can also install their language files in a subfolder in the same folder where the extension itself is installed. Therefore a text search utility is the best approach to find any obscure messages where the origin can be anywhere in the system.

Language File Example

Once you find a match in a language file, copy the language constant from the start of the line and then search for that constant from the website filesystem or its copy exactly the same way, using a utility like grep or Windows grep. This way you can identify the file or all the files where the language constant has been used and you will be able to identify the extention.

If the message is not defined in one of the language files, it would have had to be hard coded in a third party extension, for example a plugin, which you may then be able to unpublish.

 

Details
Written by: Toivo Talikka
Category: Joomla
Published: 18 May 2018
Hits: 10627

Troubleshooting SMTP connection in Joomla 3.x

If your Joomla! site has issues in connecting to your SMTP mail server, it is possible to get a detailed log of all the messages exchanged between your Joomla site and the SMTP server.  Inspecting this low level transaction log allows you to see what is going wrong between the two servers and then get your IT department or hosting provider to resolve any connectivity issues. 

Go to Extensions - Plugins and configure the system plugin 'System - Debug' with the following settings:

  • Allowed Groups: Super Users
  • Log Priorities:  All
  • Log Categories: mail
  • Log Almost Everything

 

20180425 system debug plugin 20180425 system debug logging

 

Go to Global Configuration and turn on the debug option in the System tab - Debug Settings - Debug System.  

20180425 debug settings

 

Go to the Server tab - Mail Settings and click the button Send Test Mail. 

20180425 mail settings

 

The test result, success or failure, will then get displayed as a system message, but you can download the detailed log file 'everything.php' from the Joomla log folder, usually administrator/logs, or, if your site was installed much earlier, from the /logs folder in the main Joomla folder.

20180425 everything example

 And this is the email we would like to receive from the website:

20180415 test mail

More about logging from the Joomla! Documentation at https://docs.joomla.org/Using_JLog

Details
Written by: Toivo Talikka
Category: Joomla
Published: 26 April 2018
Hits: 11396
  • Gmail as SMTP Host in Joomla 3.6.5
  • Adding Time to Logged-In Users

Page 1 of 2

  • 1
  • 2

Names Online

We have 16 guests and no members online