Page 2 of 3
Part 1: The component
For documentation on building a Joomla! component, follow this link
.For this example, the component will follow the MVC design. Since this extension does nothing else outside Linkr, it will have one controller. Moreover, the only task for the controller will be to display the translated text. So, no view is needed here. The controller needs to be able to send text over an AJAX request. Here's one way to do it:
// Hello Linkr controller class Hello_linkrController extends JController { function display() { // Get model $hello = & $this->getModel( 'hello' ); // Get the language we're translating into $lang = JRequest::getVar( 'lang', 'hr' ); // Get translation $trans = $hello->getTranslation( $lang ); // Since this is an AJAX request, // we don't need a view to display the result. // In this example, we will simply echo it // and shutdown the Joomla! application. echo $trans; // Quit Joomla! global $mainframe; $mainframe->close(); } }This can be done in a number of ways, and you should find the one that fits best into your extension.
| < Prev | Next > |
|---|



