danielbidala VIP
Total posts: 153
24 Aug 2016 08:38

I'm creating a module to extend cobalt functions. I need interact between the current list view and my modul. I'd like to get all the record IDs which are in the current list view (not only records in actual page but all of the record IDs if there is more page of result)

Is there a way? Can anyone help me?

Last Modified: 04 Oct 2016


danielbidala VIP
Total posts: 153
25 Aug 2016 06:47

If I'm not mistaken I have to operate with CobaltApi class (api.php). In that there is a function or method: public function records(). In the records function there is multidimensional array $content which contains all of the IDs that I need.

The only problem is I do not know how to reach this array from my module if it is possible anyway!


Sergey
Total posts: 13,748
30 Aug 2016 14:50

If you need all IDs I think it is best to run direct query to DB. It will be more productive then to use API method records(). This method is for display records. It does all the work of rendering.

So you need just somethoign like this

$db = JFactory::getDBO();
$db->setQuery("SELECT id FROM #__js_res_record WHERE section_id = 2 AND published = 1 AND hidden = 0");
$ids = $db->loadColumns();

danielbidala VIP
Total posts: 153
31 Aug 2016 13:46

Thanks Sergey but I need only the ids which is listed in the current list view. This could be a filtered list view. For example:

I view section=2 and I have 2 filters applied to it. I need all the ids of this filtered view in my module. Is this possible?


Sergey
Total posts: 13,748
02 Sep 2016 07:20

I am not sure it is easely possible. Of course you can run the same query and get all those records but SQL Query builder for list of articles one of the most complext thing in cobalt.

Do I understand you right that you display this module on the Cobalt page view=records? And we are talking about IDs that are displayed in cobalt view?


danielbidala VIP
Total posts: 153
02 Sep 2016 07:45

Yes, exactly as you say... I need those record IDs and only on view=records Cobalt page and always the IDs of the current view. I tought there is a variable which includes these IDs when Cobalt generates the actual page. Isn't there?


Sergey
Total posts: 13,748
09 Sep 2016 08:26

danielbidala Yes, exactly as you say... I need those record IDs and only on view=records Cobalt page and always the IDs of the current view. I tought there is a variable which includes these IDs when Cobalt generates the actual page. Isn't there?

I could give you a way to get IDs of those articles that are on thispage but not all IDs that are on the other pages.


danielbidala VIP
Total posts: 153
12 Sep 2016 13:01

Thanks Sergey, I wait for your suggestion. Although this is just a part solution for me but it will be good for start...


Sergey
Total posts: 13,748
16 Sep 2016 11:21

I added to the next version something like this

JSession::getInstance()->set('cobalt_last_list_ids', $item_ids);

so you can try to get it

$ids = JSession::getInstance()->get('cobalt_last_list_ids');

Иге I am not sure what code executed first, component or module.


danielbidala VIP
Total posts: 153
30 Sep 2016 05:57

Thanks Sergey!

Is it added?


Sergey
Total posts: 13,748
04 Oct 2016 03:53

Yes, updating today.

Powered by Cobalt