I feel like this post gives a lot of detailed information that would be helpful to me after I have learned the basics.
Unfortunately, the posts are over my head at this point: I feel like I'm reverse engineering the information. Razor syntax is clear enough: but the specifics of how create a macro with it are very unclear.
Also: Is there a library of macros that others have already done? I'm new to this platform and it seems like most of what I need others have probably already developed. I'd prefer to use existing wheels rather than create my own.
It is a complete umbraco install showing how to utilze all the built in data types, plus the uComponents data types and the DAMP media picker.
Like everything with umbraco, there are lots of ways to get the job done depending on your requirements. Here are a few of your options when working with razor macros.
1. Create a macro on the developer tab for a "razor script". This will create a macro which you can reference from your templates and a cshtml file under the macro scripts section. If you enable the "Visible in UI" option on the macro users can use the rich content editor tool bar to insert a macro. This way you can make a new "TextPage" and add your "Contact Form" macro without having to make a new template for a "Contact Page". This is really helpful if you want to give editors the ability to add macros without letting them alter the templates.
2.If you didn't enable the macro to be available in the UI then you will have to add the maro to a template You can add your macro to your template with something like this:
Wanted: Good, Clear, "Getting Started" with Razor for macros
Hi,
I'm having a hard time find a good, clear, step-by-step post on how to get started with creating a Razor macro. I've been plowing through this: http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets
I feel like this post gives a lot of detailed information that would be helpful to me after I have learned the basics.
Unfortunately, the posts are over my head at this point: I feel like I'm reverse engineering the information. Razor syntax is clear enough: but the specifics of how create a macro with it are very unclear.
Also: Is there a library of macros that others have already done? I'm new to this platform and it seems like most of what I need others have probably already developed. I'd prefer to use existing wheels rather than create my own.
Thanks.
I would suggest you start with the Cultiv razor examples. http://our.umbraco.org/projects/developer-tools/cultiv-razor-examples
It is a complete umbraco install showing how to utilze all the built in data types, plus the uComponents data types and the DAMP media picker.
Like everything with umbraco, there are lots of ways to get the job done depending on your requirements. Here are a few of your options when working with razor macros.
1. Create a macro on the developer tab for a "razor script". This will create a macro which you can reference from your templates and a cshtml file under the macro scripts section. If you enable the "Visible in UI" option on the macro users can use the rich content editor tool bar to insert a macro. This way you can make a new "TextPage" and add your "Contact Form" macro without having to make a new template for a "Contact Page". This is really helpful if you want to give editors the ability to add macros without letting them alter the templates.
2.If you didn't enable the macro to be available in the UI then you will have to add the maro to a template You can add your macro to your template with something like this:
<umbraco:macro runat="server" alias="myMacroAlias" />
3. Another quick option I am quite fond of right now is adding the razor script reference directly in my master page with something like
is working on a reply...