miojamo
miojamo

Reputation: 747

Joomla own component settings insert article in popup

I would like to make a setting to insert article ID in backend.

The scenario is: User can click on a button, window with article list will appear, than can choose the article. Article ID will be stored in component config.

Than I can populate article in frontpage (this part I know)

Upvotes: 0

Views: 882

Answers (1)

Alex
Alex

Reputation: 6470

You need to do the following:

  1. Add path to joomla content article element
  2. Create instance of that element
  3. Display it

`

<?php
//  I created the element inside of the view, $this is my View. 
//  It can be model/view/controller. Does not matter

//  Include Element
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'elements' . DS . 'article.php';

//  Create Instance
$articleElement = new JElementArticle($this);

//  Output article
echo $articleElement->fetchElement('article', 0, $this, 'myparam');

//  NOTE: name of article_id  element will be myparam[article]
?>

If you want to change the way element looks, you need to overload/modify element. It is pretty easy to do, you can copy site/administrator/components/com_content/elements/article.php, make changes and you will get your own version of element. Do not modify article.php component, you will mess up things for Joomla and if you plan updating your site in future... you'll loose changes after update.

Upvotes: 1

Related Questions