phpjoomlajoomla-component

Joomla: Is it possible to display a view of a component without iframe and plugin?


Is it possible to display a view of a component without iframe and plugin? (That is to say, if possible with a few lines of PHP and maybe SQL queries?)

EDIT: To be more clear: I'd like to do it directly in the PHP-Template! (Would be fine to do it in an article as well, as I have written a PHP-function showArticle(mixed $ident))

(I'm using Joomla 3.5)

I'd like to do something like

<jdoc:include type="component" view="example" name="position-x" />

or

<?php
    show_component('component-name', 'view-name');
?>

Solution

  • you can use this component http://extensions.joomla.org/extension/components-anywhere Install the plugin and enable it. Then you can call the component this way {component url/of/the/component}

    {component index.php?component=com_example&form=1}

    Try to use non-sef urls in the url but sef url will still work.

    There is another way to achieve this by calling the model into your controller file this way

    JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_example/models', 'ExampleModel');
    

    What this does is it searches the model class starting with ExampleModel in the folder specified. here you can eneter just a path string or array of the directories as the first parameter. Next you have to call the method inside the views file this way

    $exmodel = JModelLegacy::getInstance('Something', 'ExampleModel', array('ignore_request' => true));
    

    So here you create an instance of the class object which can be used to get the items from the model this way

    $items = $exmodel->getitem();
    $this->assignRef('items', $items);
    

    next you can copy the default.php file in the tmpl folder of that component and place it anywhere you like inside your layout file. Basically instead of copying the entire component you are calling the model and getting the data which you can use in your layouts.