OctoberCMS部分共享变量生命周期

时间:2019-02-16 23:51:42

标签: components octobercms partials

我十月份是CMS的新手,我尝试开发一些组件,这些组件有一页以上。我将每个页面作为部分页面包含在default.htm文件中,if条件取决于页面的type属性。

{% set type = __SELF__.property('type') %}
{% if type == 'y' %}
{% partial 'x::yy' %}
{% elseif type == 'x' %}
{% partial 'x::xx' %}

问题是,当我在一个页面中有一个项目集合并将一个项目的ID发送给另一个Ajax处理程序,并想检索该项目的完整信息时,由于存在以下原因,我无法将其传递给下一页十月CMS的页面循环。例如:

// firstpage
{% set posts = __SELF__.posts %}
{%for post in posts%}
<button data-request="handlerX" data-request-data="id: {{post.id}}">
{%endfor%}


//hanlerX
public function onHanldlerX(){
  $post = $this->post = POST::where('id',post("id"))->first();
  return redirect()->to('/my-posts/'.$post->slug);
}

//nextpage -> my-posts/$post->slug
// post informations is unavailible

这些类型的组件的最佳方法是什么? 这是正确的方法吗? 如何在组件中的OnRun方法之后发送变量以进行查看?

0 个答案:

没有答案