0

I'm having some problems with a custom module that I'm making to display some basic "logged in" user information.

I'm working on a template with "SP Page Builder" CMS.

My module:

{source}
<table style="width: 100%; border-top: 0px solid #bb141b !important;">
    <tr>
        <td style="border: none !important;" width="84px">
            <img src="/images/2022/01/16/star-of-life-variant-colors-08.png" alt="nord-als-logo" width="70px">
        </td>
        <td style="border: none !important;" width="*">
            <strong><?php echo $user->name; ?></strong><br>
            <small>...</small>
        </td>
    </tr>
</table>
{/source}

I would like to replace the "..." with the field value named jform_profile_Stilling.

I would also like to fetch the profile picture -- I found this label jform_params_profilepic.

2
  • Welcome @Mark and thanks for your question. Please take our tour while you wait for support/feedback. Apr 20, 2022 at 13:57
  • What Joomla version do you use?
    – pe7er
    Apr 20, 2022 at 16:15

2 Answers 2

0

What kind of "custom module" are you trying to develop?

Joomla's default Module of type "custom"

An existing Module of module type "custom" to display custom HTML in your site. See https://docs.joomla.org/How_do_you_create_a_custom_module%3F Such a custom module does not know anything about Joomla / users outside its module scope.

Programming your own Module

A Joomla module developed from scratch and install-able via the Joomla extensions installer. See https://docs.joomla.org/J3.x:Creating_a_simple_module/Developing_a_Basic_Module

In such a module you can do some database queries to get the information you want and display it on the screen. "SP Page Builder" is a commercial extension. I do not know how it exactly stores its information in the database.

2
  • Im trying to display information about the user who is logged in :)
    – Mark
    Apr 21, 2022 at 14:12
  • Yeah, I understand that. But what kind of Module are you trying to create? In Joomla back-end: Extensions > Modules > New > Type "Custom" (HTML). Or are you programming your own Joomla Module using PHP/MySQL?
    – pe7er
    Apr 22, 2022 at 7:07
0

I have a component that is using custom fields that are attached to the com_users component. The code I use is below.

$this->user = Factory::getUser();
$this->userFields = FieldsHelper::getFields('com_users.user', $this->user);
$this->fields = array();
foreach($this->userFields as $k => $field){
    $f = new stdClass();
    $f->title = $field->title;
    $f->value = $field->value;
    $this->fields[$field->group_title][] = $f;
}

After getting everything into the $this->fields array, I then just call the results where I need them. In my case, I am displaying the values as a part of a tab set.

<?php foreach($this->fields['YOUR_FIELD_GROUP_NAME'] as $fieldInfo){?>
    <div class="fieldLabel"><?php echo $fieldInfo->title;?></div>
    <div class="fieldValue"><?php echo $fieldInfo->value;?></div>
<?php }?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.