According to this section of the OctoberCMS documentation, it should be possible for me to set up a directory structure like this:
pluginname
├── components
│ ├── resumefilter
│ │ ├── default.htm
│ │ └── my-partial.htm
│ ├── ResumeFilter.php
│ ├── resumelist
│ │ └── default.htm
│ └── ResumeList.php
Then, I should be able to put a function in ResumeFilter.php
like this:
function onFilterResumes()
{
return ['#someDiv' => $this->renderPartial('my-partial.htm')];
}
Finally, a button in the default.htm
markup:
<button
class="btn btn-success"
data-request="onFilterResumes">
Filter
</button>
The problem is, when I press the button, it says The partial 'my-partial.htm' is not found
I've tried it with the full path but it doesn't seem to make any difference.
October seems to be looking in the theme partials directory for the partial because it loads if I put it in there. However, prefixing the name with resumefilter:
to try and get it to look in the component isn't working, and the docs seem to suggest that it should be looking in the component without a prefix.
I found this bug on github from 2 years ago but it looks like it was fixed.
Add @
before your partial name if you want to render component partial. So your code should like this,
function onFilterResumes()
{
return ['#someDiv' => $this->renderPartial('@my-partial.htm')];
}
And if you want to override the partial in your theme, put the partial in the following tree,
themes/theme-name/partials/component-name/my-partial.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With