0

I m trying to send mail which contain some data along with embedded view result programmatically. This mail is trigger on submit of webform. Webform ajax property is enable. Due to which it send incorrect url.

Used below code

$view = Views::getView($viewID);
$view->initDisplay();
.....
$vars['result_table'] = $view->buildRenderable('email', $contetxtualFilter);

In twig file

{{ result_table }}

Here output of first page is send in mail correctly but the pagination link has incorrect url.

Ex of incorrect pagination link of Page 1 is - "?_wrapper_format=drupal_ajax&ajax_form=1&page=0"
Ex of correct pagination link of Page 1 is - "www.test.com/productone?page=0"

Do you have any idea, how can I send correct pagination link in email without turning off webform ajax property. So that when user click on pagination in mail he is redirect to specific page.

2
  • Seems like you have ajax enabled in your view settings. Try turning off and see if it sends correctly in email.
    – No Sssweat
    Commented Mar 10, 2023 at 11:38
  • Already checked but still same issue.
    – Sudha
    Commented Mar 10, 2023 at 11:43

1 Answer 1

0

It seems that the incorrect pagination link is being generated due to the _wrapper_format and ajax_form query parameters being added to the URL. These query parameters are used by Drupal to render views using AJAX, but they should not be included in a regular URL.

To fix this issue, you can try setting the use_ajax option to false when building the renderable array:

$vars['result_table'] = $view->buildRenderable('email', $contetxtualFilter, null, ['use_ajax' => false]);

This should generate the correct pagination links in the email.

3
  • Even without passing any argument it still show incorrect url. Also after trying above solution it still shows the same.
    – Sudha
    Commented Mar 10, 2023 at 13:18
  • Is above code is updated in question is it a full code ?
    – Vikram8888
    Commented Mar 10, 2023 at 13:29
  • Yes.. I figure out issue. Usually I send mail on submit of webform. So the Webform ajax property was enable due to which pager link were generated in ajax format.
    – Sudha
    Commented Mar 10, 2023 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.