I just build my first plugin with OctoberCMS Builder Plugin. I'm having trouble when I try to show the plugin data on the front-end.
I have created a component, but there is some code missing in the component.php and default.htm. I don't know which values to use when reading the documentation cause my technical English is not so good.
This is the last piece I would like to learn so I can build my own plugins, can someone help me out please? Here is the link to the plugin:
https://github.com/Hessel91/activiteiten
P.s: I know how to output the data with the builder component but I would like to learn how to do it with my own component.
In your component it is missing onRender
method which is used for setting data to page
and then you can access it in view default.htm
in your component activiteiten/hessel/activiteiten/components/Activiteit.php
public function onRender()
{
$this->page['records'] = \SomeModel::find();
// $this->page['records'] = $this->someData();
}
// OR MAY BE THIS
public function someData()
{
return [
['name' => 'hardik'],
['name' => 'hitesh'],
['name' => 'new name'],
];
}
and inside partial activiteiten/hessel/activiteiten/components/activiteit/default.htm
you can use this code
{% for record in records %}
<h1>{{ record.title }}</h1>
{% endfor %}
<!-- OR MAY BE THIS -->
{% for item in __SELF__.someData() %}
<h1>{{ item.name}}</h1>
{% endfor %}
For suggestion you need to read this document:
if you find any issue please comment.