List Manager Forum

custom option list

User moon_1487 2014-02-20 12:59:17

Hi,
I have two lists ( A and B)
The list A has ID,VALUE, User fields (only own records)

In the B list I want to create a custom option list with the values of A list

I put the sql stament for populate the option list, but the list appears with all the values of A inclusive values from others users,
How can i create the option list with the values of A but only the own records not all records.

Moonsoft support 2014-02-20 16:35:49

Hi,
you can't get that kind of filter using plain sql because you can't write a sql query dependant on active user ID. You will need to write a more complex query, filtering only the record ids containing the user id, and a code tweak able to introduce the active user at the query. So, you will need a query where you use userid with a special enclosure,like:

select........where.....fielduser=##userid##


and introduce a change at source code before launching the query:


joomla\modules\mod_listmanager\helper.php

about line 159 you will find the function

public function getExecuteQuery($query) {

//introduce this line to replace ##userid## for actual user id

$query= str_replace("##userid##",JFactory::getUser()->id,$query);

$db->setQuery($query);
return $db->loadRowList();
}

Hope this helps, regards

Moonsoft support 2014-03-07 18:15:17

FYI - Experimenting with that technique, it seems that one must place ' ' marks around ##userid## in "select........where.....fielduser=##userid##", i.e., "select........where.....fielduser='##userid##'"

Edited by moon_1371 - 07.03.2014 18:44

Moonsoft support 2014-03-07 18:50:20

I have a similar problem with the userids of rows in a View of a List that has 3 fields:
User Id - type User internal name "user"
Description - type Text
fname - type Option List with SQL Action" "Select id,firstname from ove83_comprofiler where id = '##user##'"

I want to list the first name of the user for that row of the List. How can I do that please?

Moonsoft support 2014-03-07 19:35:44

Will the helper.php revision be lost with each new release of ListManager and have to be reentered each update? Or can you make support of "##user##" a feature of the next release?

Moonsoft support 2014-03-10 09:12:34

FYI - Experimenting with that technique, it seems that one must place ' ' marks around ##userid## in "select........where.....fielduser=##userid##", i.e., "select........where.....fielduser='##userid##'"

Edited by moon_1371 - 07.03.2014 18:44


Hello,

This depends on database table column type. You will only need ' ' if column is char type.

Regards,

Edited by MSTeam - 10.03.2014 09:12

Moonsoft support 2014-03-10 09:28:32

I have a similar problem with the userids of rows in a View of a List that has 3 fields:
User Id - type User internal name "user"
Description - type Text
fname - type Option List with SQL Action" "Select id,firstname from ove83_comprofiler where id = '##user##'"

I want to list the first name of the user for that row of the List. How can I do that please?


Hello,

Your work seems to be ok: when users use add form, fname field will show a select with only one option, so this form will save the name (use 'Select firstname,firstname...'). This is not valid if you want to add data from backend as user logged is administrator.

Setting field data with an SQL depending on data in the same row is not possible. Maybe you will need to add custom code in List Manager.

Regards,

Moonsoft support 2014-03-10 09:45:22

Will the helper.php revision be lost with each new release of ListManager and have to be reentered each update? Or can you make support of "##user##" a feature of the next release?


Hello,

Maybe you should need to reentered your tweak, as, by now, this is not planned to added to new releases.

Regards,

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
List Manager

Build different lists for your site

Buy now!