douganbi7686 2013-10-24 19:08
浏览 6

Cakephp在一个动作中分页两个模型

I have a comment system based on the page path of the website. In other words, every page should be commentable and list comments. I have paginated list for the posts, in-which every page contains 5 posts, it may be accessed something like the following:

http://mywebsite.com/posts
http://mywebsite.com/posts/page:2
http://mywebsite.com/posts/page:3
etc

Now, let says that I have comments should be paged on http://mywebsite.com/posts/page:2 with 10 comments per the page, this should mean that posts/page:2 should has the first 10 comments and I need something like /posts/page:2/comments/commentsPage:2 to render the next 10 comments in the /posts/page:2.

How could I achive something like that?

  • 写回答

1条回答 默认 最新

  • duanjiao8871 2013-10-26 22:21
    关注

    This ist not possible:

    /posts/page:2/comments/commentsPage:2
    

    You should use your Posts Model for the posts (as I believe you do) and a Comment Model for the comments.

    Then you can link your Posts and Comments.

    Check out: http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大