Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:43+00:00 2026-05-28T00:09:43+00:00

I am building a Joomla module which will eventually pull data from an external

  • 0

I am building a Joomla module which will eventually pull data from an external data source. Right now while I learn, I set it to simply print the string “This bit works correctly” to the module position. However, I have been having problems getting it to work correctly. Here is my code:

mod_ucr.php:

<?php
/**
* UniversalContentRepository Module Entry Point
* 
* @package    UniversalContentRepository
* @subpackage Modules
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );
$helper = new modUCRHelper();
$content = $helper->getSnippetContent();
require( JModuleHelper::getLayoutPath( 'mod_ucr' ) );
?>

mod_ucr.xml

<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
    <name>Universal Content Repository</name>
    <author>Brendon Dugan</author>
    <version>1.5.0</version>
    <description>A module to allow the insertion of UCR Snippets into a Joomla site.</description>
    <files>
        <filename>mod_ucr.xml</filename>
        <filename module="mod_ucr">mod_ucr.php</filename>
        <filename>index.html</filename>
        <filename>helper.php</filename>
        <filename>tmpl/default.php</filename>
        <filename>tmpl/index.html</filename>
    </files>
    <params>
    </params>
</install>

helper.php:

<?php
class modUCRHelper
{
    function __construct(){

    }


    public function getSnippetContent($id = 0){
        $content = "This bit works correctly, ID = $id";
        return $content;
    }
}
?>

tmpl/default.php:

<?php // no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
echo $content; 
?>

Here we set the variable $content to be the output of the getSnippetContent() method of the helper class. This method is currently:

function getSnippetContent($id = 0){
    $output = "This bit works correctly";
    return $output;
}

Which simply outputs the string I want to print. In my template, I should be able to echo content like this:

<?php // no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
echo $content; 
?>

But what the module outputs instead is

"This bit works correctlyThis bit works correctly"

If I comment out the echo statement, the string is still echoed once, suggesting that the return statement itself is echoing.

I adapted my code from the “Hello World!” example located in the Joomla documentation. Any Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:09:44+00:00Added an answer on May 28, 2026 at 12:09 am

    This is Core joomla code for displaying module

    $content = '';
    ob_start();
    require $path;
    $module->content = ob_get_contents().$content;
    ob_end_clean();
    

    It uses the $content variable itself. And your module is changing the value of $content. One output is from your module and another is due to this joomla code. It appends the content of your module to $content variable (which has been changed in your module).

    So do not use $content variable in you code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build a news scroller module for a website in Joomla (
I am using windows, Mysql DB, PHP I am building the Joomla Component whose
I have a custom Joomla component and a router for building my SEF URL's
I'm building up a custom component, which should only be accessible to logged in
I am building a CMS for a client, and I needed some inspiration from
building on my last question jQuery getting values from multiple selects together I have
While building our project on the Build Server, the compilation fails with the error
While building this web service and the app that calls it, we have noticed
building upon the $.fn.serializeObject() function from this question , i'd like to be able
Building an iPhone application. The delegate loads a SplashScreenView which sits there until the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.