5

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.

Joseph
  • 2,737
  • 1
  • 30
  • 56
  • The error is complaining about `my-partial.html` which clearly does not exist. Are you sure you are using correct file name? – B Faley Feb 19 '17 at 11:32
  • Thanks for spotting that @Meysam but that was just a typo on my part. I've updated it now. The error was in a javascript alert which I couldn't copy/paste :-) – Joseph Feb 19 '17 at 11:43

1 Answers1

7

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

Surahman
  • 1,040
  • 9
  • 15