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

Not applicable

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.

2707-smartdocslimitissue1.jpg

2708-smartdocslimitissue2.jpg

2709-smartdocslimitissue3.jpg

regards,

Vishal Bhatnagar

Solved Solved
2 22 334
2 ACCEPTED SOLUTIONS

@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 ?

View solution in original post

Not applicable

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

View solution in original post

22 REPLIES 22

Not applicable

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 ?

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.

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

Thanks for that solid answer, Anil!

@ Thanks all for the update.

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;
  }
}

This should do the trick:

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

Not applicable

@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

Not applicable

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

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 🙂 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.

Thank you for the update @Daniel Johnson , It helps. @Madhan Sadasivam FYI

Not applicable

The fix for this issue is now available as part of today's cloud release 16.06.22.00.

Awesome @Daniel Johnson , Works like a charm... Looking forward to same feature on OPDK. @Madhan Sadasivam , FYI. We should update our client who is looking forward to this feature on cloud. Great work Developer Services team !!