How to get module's title in Joomla 2.5?
Asked Answered
S

2

10

Inside my module (from within php code), say mod_mymodule, how can I retrieve my module's title, in case an administrator has changed it from the module management page?

Is it possible to retrieve the "Status" and "Position" the same way as the title?

Simpleton answered 26/6, 2013 at 9:3 Comment(0)
D
15

Inside the module, there are two helpful variables available: $module and $params.

You are looking for $module->title.

Deadeye answered 26/6, 2013 at 9:42 Comment(0)
G
12

Try the below code.

<?php
  if ($module->showtitle) 
  {
    echo '<h2>' .$module->title .'</h2>';
  }
?>

You can access the following things.

stdClass Object
(
    [id] => 18
    [title] => Login Form
    [module] => mod_login
    [position] => left
    [content] => 
    [showtitle] => 1
    [control] => 
    [params] => greeting=1
                name=0
    [user] => 0
    [name] => login
    [style] => 
)  

Reference Joomla URL:
1. http://docs.joomla.org/JModuleHelper/getModule
2. http://docs.joomla.org/Customising_the_way_modules_are_displayed

Updates - 22nd Dec 2016

You can use jimport to get the module.

jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'login' ); // Single
$module = JModuleHelper::getModule( 'mainmenu', 'Resources' ); // Multiple
Govern answered 26/6, 2013 at 9:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.