tags:

views:

50

answers:

1

Hi,

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)

+1  A: 

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.

Alex
WOW I'm impresses how things can be simple in Joomla :) Thanks a lot!!!
miojamo
They are simple... but you need to know things. Understanding Framework is very important, if you want to learn more in-depth about framework bookmark this page http://docs.joomla.org/Framework. Knowledge is power!
Alex