40 Posts
philippe_du_56
9 years ago
Topic

Hello,

I try to use the field 42 #

I want a list of aticle with author filter

For PrepareForm:

$db = JFactory::getDBO();
$user = JFactory::getUser();
$query = 'SELECT c.created_by, u.name' .
' FROM #__content AS c' .
' LEFT JOIN #__users AS u ON u.id = c.created_by' .
' GROUP BY u.name ORDER BY u.name';
$db->setQuery($query);
$authors = $db->loadObjectList();
$form = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid);

mo problem is the following

how to display the value of this field in the list

For PrepareContent:

$value = ????

Image 1

image 1

Thank

Get a Book for SEBLOD
154 Posts
WebOne
9 years ago
3
Level 1

Have you tried to do it this way?

Create a new field of type SELECT DYNAMIC 

but store the data in created_by (ie. duplicate field of Article Created By)

Use SQL query FREE

and then add this field in as a filter in your search/list type.

40 Posts
philippe_du_56
9 years ago
2
Level 2

Hi,

yes i try this way . But this result  is the "id" not the name.

helpe me please!!

Best regards

154 Posts
WebOne
9 years ago
1
Level 3

Firstly I see you are using the Joomla user object :

$user = JFactory::getUser();

But where are you using this in your query or why do you have this?
 
In SELECT DYNAMIC you'd use : $user->id  (for example to retrieve the userid of the current user viewing the page)

also in SELECT DYNAMIC you would use something like :

SELECT c.created_by AS value, u.name AS text ....

where created_by would be the value in the dropdown (hidden) and the name (text) would be shown in the dropdown.

40 Posts
philippe_du_56
9 years ago
0
Level 4

Hi,

thank you it works !!!

best regards

Get a VIP membership