Thursday 27 November 2014

To add the submenu on Left Sidebar on custom component in Joomla 3.x.x

In latest version of Joomla (3.3.6+), if you are looking to find a way out to add new menu/navigation on the left sidebar list within Administrative view (of your custom component or existing component), please follow as below;

In fact, you can do from two places based on your requirement.
  1. First, if you just need to show under one particular submenu link, then please add on  administrator/components/com_yourcomponent/views/photos/view.html.php, within the display() function. But, make sure you are calling the addEntry() function before the JHTMLSidebar::render().
    // To fine all the entries currently exist on the Submenu List
    $menu_entries = JHtmlSidebar::getEntries();*/
    //print_r($menu_entries);
    
    
    // To add new menu item to submenu on the Left Sidebar
    JHtmlSidebar::addEntry('Configuration', 'index.php?option=com_yourcomponent&view=photos&layout=configuration'); // NameOfMenu, URL_Of_The_Menu
    JHtmlSidebar::addEntry('Export', 'index.php?option=com_yourcomponent&view=photos&layout=export');
    
    // Show sidebar
    $this->sidebar = JHtmlSidebar::render();
    

  2. Or you can directly add within the administrator/components/com_yourcomponent/yourcomponent.php file as below;
    // import joomla controller library
    jimport('joomla.application.component.controller');
    
    // To add new menu item to submenu on the Left Sidebar
    JHtmlSidebar::addEntry('Configuration', 'your_url'); 
    JHtmlSidebar::addEntry('Export', 'your_url');
    
    
    

Friday 14 November 2014

Converting php version of \r\n to line breaks in a textarea (without using a
tag)

If you are using a text area for input form field and you want to display the output on view/edit version, and if sometimes find \r\n is displaying instead of line breaks;

This could be because of single quote string format, in such case even if you use nl2br() function, it wouldn't work either. In such case, you may need to use the double quotes on str_replace which interesting would work.

Please use the below format in such case;


$yourStringHere = str_replace('\r',"\r",str_replace('\n',"\n",$yourStringHere));

echo '';