4

I want to have an article picker in my custom module. A button and a form field like this one in add new article.

Is ist possible? I tried this in my module xml:

                <field name="article_id" type="modal_article" default="" label="Select an article" description="" />        

But I only get a form input, not a button to choose an article.

sunny
  • 53
  • 1
  • 3

1 Answers1

7

You need to manually add the path to the modal article element. In the < fieldset > element just above the modal_article field type, add the following attribute:

 addfieldpath="/administrator/components/com_content/models/fields"

So your final xml would look something like this:

<fieldset name="basic" addfieldpath="/administrator/components/com_content/models/fields">
<field name="article_id" type="modal_article" default="" label="Select an article" description="" />
mozami
  • 7,391
  • 4
  • 21
  • 20
  • Now I have a link to my article like "index.php?option=com_content&view=article&id=17". But is it possible to get the link with the aliases? ...like a menu link /test/mysite.html – sunny Sep 26 '13 at 08:01
  • Is SEF enabled on your site? – mozami Sep 26 '13 at 09:17
  • I am on Joomla 2.5 and tried to apply the same solution. I was able to add the field but the labels are not correctly translated. I only see: `COM_CONTENT_SELECT_AN_ARTICLE` instead of the correct text string. Any idea what I must change for 2.5? – lanoxx Dec 12 '13 at 23:09
  • once done... how would you grab this and make it a link to the article? via the php file - as mine just links to the article ID - i.e. http://localhost:8888/joomla32/1 – user991830 Dec 20 '13 at 11:12