How to customise Smartdocs-Method-Listing-View's number of items size.

When we create a model and upload a swagger file and render and publish it, a corresponding smartdoc view gets created with setting of displaying no of items as 5.

Steps to reproduce : Content → SmartDocs → New model → Add model name → create model →

Import-> Choose Swagger JSON file → Import → render and publish nodes.

corresponding smartDoc view will get created, with settings as below :

Use pager:Display a specified number of items | 5 items.

Structure → Views → select your API method listing → Edit → you will see limit is set to 5.

Instead of changing each APIs method listing views setting, we should be able to produce views with customised limit of no. of items to display.

I have also tested by changing settings of base method listing view of smartdoc, but that is also not helping in creating views with customised limit values.

Any help on this is highly appreciated.

regards,

Vishal Bhatnagar

Hi @Anil Sagar ,

could you please help on this .

@Vishal Bhatnagar ,

I am afraid, as of today when creating a new view, it picks up settings from module code instead of view database. Ideally, As you said, it has to pick up settings from overridden base view while creating SmartDocs Views Listing page.

You need to update those settings manually today & it will be one-time update.

@Chris Novak , @Daniel Johnson What do you think about same ?

1 Like

Anil’s answer is correct, the SmartDocs module should pick up the overridden view. I put in an issue for the development team to add this fix, but for now you will need to modify each new API view individually.

2 Likes

Thanks for that solid answer, Anil!

Thank you @Chris Novak for the update. Just FYI, Few other customers (Kronos) also looking for similar solution.

@ Thanks all for the update.

@Anil Sagar @Chris Novak @Daniel Johnson

Could you please suggest me in which database table the value get updated for pager limit?

-regards,

Vishal Bhatnagar

Could you please suggest me in which database table the value get updated for pager limit?

@Vishal Bhatnagar , It’s not a good idea to directly change database values. It will lead to fatal errors & you will bypass drupal system. Any reason why you are not using UI to update the values ?

Hi @Anil Sagar, We have even more than 100 views to update, manually changing values for all would be tedious, therefore thought by updating all view’s value at once using db update.

@Vishal Bhatnagar ,

You can achieve same with simple hook & custom module. See details below. For more information check here.

/*
 * Implementation of hook_views_pre_build().
 */
function YOURMODULENAME_views_pre_build(&$view){
  // Make sure this is only for smartdocs related views
  if (CONDITION TO MATCH ALL SMARTDOCS VIEWS) {
      // Now lets set the pager item to what ever out count is.
      $view->pager['items_per_page'] = 10;
  }
}

We have a fix for this issue which is currently undergoing testing, and it should be available in the next release.

2 Likes

This should do the trick:

if ($view->tag == 'smartdocs') {
  // Set pager count.
}

1 Like

Awesome @Daniel Johnson , Glad to hear fix will be available in next release.

Thanks @Anil Sagar, @Daniel Johnson for you help and support.

Anytime @Vishal Bhatnagar :slight_smile: Great Question & Thank you for asking same. I am sure, it will be helpful for many others once we fix same in next release.

@Daniel Johnson , Fix will be available in onPrem version too right ?

@Daniel Johnson , One of our customer is looking for the same fix, Is it available on portal now ?

This fix did not make it into the June 16 release because with a very small number of exceptions that was a security hotfix release rather than a bugfix/feature release. We are planning a new feature/bugfix release soon (exact date TBA) which will include this fix. Unfortunately it did not make it into the recent on-prem release either.