We have moved to GitHub Issues
Created by Casey Neehouse 19 Aug 2013, 13:23:09 Updated by Shannon Deminick 12 Sep 2013, 04:57:05
Relates to: U4-2815
There is a restriction that the Partial View Macro file can not be anywhere other than ~/Views/MacroPartial. This restriction throws an error.
I am wanting to dynamically swap the file to a 'themed' location. Request that the location validation be removed or at most validate the file is in the root path of the site.
Pull request: https://github.com/umbraco/Umbraco-CMS/pull/131
I've looked in to why we throw an exception there and there's a reason for it. The macro system is currently a mess and the db table that stores macro information is not adequate to specifically determine a macro type based on the information that is in there. If you have a look at:
This is the method that determines a macro type based on the information in the db table. You can see the logic in the test:
If you change the path of a partial view macro to not exist inside of: "/Views/MacroPartials/" or "/App_Plugins//Views/MacroPartials" then it will not be determined to be a "Partial View Macro" and instead will be treated like a legacy razor macro.
Unfortunately there's not much we can do about this without upgrading the macro db table. I'd also like to overhaul the whole macro process: http://issues.umbraco.org/issue/U4-700
I'll have to close your pull request since this will actually produce some errors in the long run.
What you can do in the meantime is have each theme inside the folder:
and it would work.
I realize this isn't ideal but we need to fix the db table and engines to properly support this.
"Ok. Not sure what i can do then. The macro type is already set by the point this error is thrown.
If what you are saying is true, how would the error ever be hit? Does it matter then?
My file paths are set in code, not via the macro."
So what is the file path of your macro in the database?
I'm assuming then that you are saying that the macro type has been determined based on the correct file path set of the macro in the database and then you are changing at runtime?
If that is the case then yup sure it will work.
That makes more sense if that is the case since I wasn't sure how the macro engine would have been executed in the first place. I've re-opened the pull request but need you to fix up the code that was commented on.
That is correct. The database has a standard path and file. I swap at runtime to themed variation.
Ok cool, if you wanna just fix up the pull request I'll merge it in (have commented inline on the codeblocks https://github.com/umbraco/Umbraco-CMS/pull/131)
I resubmitted the pull request. Thanks Shannon!
Cool will pull it in but I'm going to modify your events as they're still not quite right, will let you know once updated so you can review. Cheers!
All done, if you wanna have a look here: dcd5decd3a5ba94ebf6d11b2b74f77d4ca24c341
Type: Feature (request)
Assignee: Shannon Deminick
Backwards Compatible: True
Due in version: 6.2.0