One hiccup I discovered was that the wrong routes were being used for any custom content blocks, even those that come from the sanctioned bcms_blog plugin.
To duplicate the issue,
- navigate to the cms content library: http://localhost/cms/content_library
- select one of the custom content block category types (e.g., Blog, if you have the bcms_blog plugin installed)
- create new content and edit and publish it several times
- list the entries (e.g., Blog > Blog Post)
- click on the entry that you edited
- click on 'List Versions'
- click on one of the versions
- click on 'View Content'
Why is the page not found? Take a look at the route. It suggests that the resource be found under the 'cms' namespace. That seems to be the problem; the bcms_blog uses its own namespace (bcms_blog) to avoid route conflicts. So what's responsible for putting 'cms' in the view links. The correct namespaces are used up until 'List Versions' is clicked and the page is refreshed.
I tracked down the issue with the JavaScript to the app/views/cms/blocks/versions.html.erb view. The existing code was assuming that all custom content blocks use the 'cms' namespace. This may not be the case, as with the bcms_blog plugin that has it's own Rails::Engine and, consequently, it's own route namespace.
By introducing some logic in the view's JavaScript, we can dynamically determine what namespace should be applied:
And the code to determine 'cmd_namespace'...
There are certainly more elegant solutions, but here is my short term solution with an idea of how to solve it better.


No comments:
Post a Comment