在Drupal自定义模块中获取ajax分页值



我有幻灯片页面来自视图

页面网址: http://localhost.com/entertainment/word

在此页面中,我有幻灯片,其中包含上一个和下一个按钮。

当我按下一步按钮时,它会调用视图 ajax 并通过附加 ?page=2 转到下一张幻灯片,然后 URL 变为"http://localhost.com/entertainment/word?page=2"而不刷新页面

每次 ajax 调用后,我需要在自定义模块中获取附加的值,例如 page="2"。

由于它是 ajax 调用,我想你应该使用 JS 获取页面值。

    document.URL.split("page=")[1]

如果需要检索模块(服务器端)中的活动页面,则可以使用 pager_find_page 函数。

这将根据 page 查询字符串参数返回活动页的整数。

  • http://localhost.com/entertainment/word 将返回 0
  • http://localhost.com/entertainment/word?page=2 将返回 2
  • 等。。。

我已经完成了会话。

在视图页面中被 nid 并分配给 seetion 变量。

在 .module 文件中获取该会话变量。

最新更新