1

I know that we can get text of an article as:

public function onContentPrepare($context, &$article, &$params, $limitstart=0){ 
    print_r($article->text);

Now is there any way to get text of module that is designed from Custom HTML using editor?

Anant
  • 534
  • 11
  • 40

1 Answers1

2

You can use this snippet:

$module = JModuleHelper::getModule('custom', 'Custom Html');
$module->content;

Where the first parameter is the module name (for this question is always gonna be 'custom' ) and the second parameter is the module title ('Custom Html' in this example)

Api Docs

enter image description here

UPDATE

I've forgot to mention, the module requested must be published and set to appear in the current page. If it's a module that I would access only programmatically, I would publish the module on all pages in a position no used by any template

enter image description here

enter image description here

Cesar
  • 4,076
  • 8
  • 44
  • 68
  • Are you sure I can call it in my function onContentPrepare? As it gives me this error: `Trying to get property of non-object in /home/agarg/public_html/joomla34/plugins/content/modulebox/modulebox.php on line 36` Also on vardump($module) results in NULL – Anant Jul 31 '15 at 04:56
  • @Anant Did you resolve your problem? Did you pass the correct params to `JModuleHelper::getModule`? – Cesar Oct 18 '15 at 05:40
  • Yes I did it as per your suggestion – Anant Oct 19 '15 at 08:09