MadeMyDay / PageTableExtended

Extends the Processwire PageTable field for rendering table row layouts.
15 stars 11 forks source link

Problems due to different template paths between `render` and `renderTable` #6

Closed jordanlev closed 10 years ago

jordanlev commented 10 years ago

In relation to my now-closed PR #5, I think the problem I'm having is due to the fact that the normal "render" function (which I believe is called when the field is displayed on the front-end of the site) uses the normal PW behavior of checking for an "alt filename", etc etc... but in the "PageTable Render Layout Options" one can specify a separate "Path to Templates" which is used only when the editing table is rendered (in the admin dashboard).

This is problematic for me because I want to use the same file for rendering both (and then within that file I will use the $options['pageTableExtended'] setting to determine if this is a front-end display or an editing display).

So I guess my question is: can this module be altered such that the "Path To Templates" setting is utilized in the render function as well (like it is currently being used in the renderTable function)? I unfortunately don't understand enough about the internals of PW to know the best way to achieve that.

If that is not a possibility, then I suggest at least making a change to the renderTable function so that it takes into account the "altFilename" setting of a template, for example:

$ext = "." . $this->config->templateExtension;
$template_name = $p->template->altFilename ? basename($p->template->altFilename, $ext) : $p->template->name;
$parsedTemplate = new TemplateFile($this->config->paths->templates . $this->pathToTemplates  . $template_name . $ext);

Thanks!

MadeMyDay commented 10 years ago

So I guess my question is: can this module be altered such that the "Path To Templates" setting is utilized in the render function as well (like it is currently being used in the renderTable function)?

As in the other thread stated, I wouldn't change the usual render process in the frontend. As for your other suggestion: This seems legit. I think in the beginning the module worked even with alternate template file names since the pure $page->render() surely uses the alternate file if present. So perhaps another solution could be to check if an alternative template path is given otherwise use the usual render process. Have to check that.

jordanlev commented 10 years ago

I just submitted a pull request (#7) with my code from above, which now uses both the PageTableExtended's "Path to Templates" setting AND the template's "altFilename" setting.

jordanlev commented 10 years ago

fixed by #7. thanks