MVC + Templates - asp.net

I am working on a system that gets templatse dynamicly, they contain tags like {{SomeUserControl}} {{SomeContent}}
I was wonder how I could use MVC to render those templates and replacing the tags in the best possible way as the templates will be edited via a web front end, and the content / macros will be create from the same web front end.

You might wanna take a look at maybe using another view engine, here are some examples.
NHaml
Spark
NVelocity
Brail
I'm sure there are many more but these are the ones I could think of.

Related

Can Sitecore templates be used to store SQL Queries or JavaScript

We are building a Page with dynamic functionality using ASP.NET + Sitecore 7.0.
Is it practical and appropriate use Sitecore templates for:
SQL Stored Procedure Name to be invoked
JavaScript to be invoked
ColumnNames to be used etc (related to coding customization)
Or should these configuration properties remain inside the ASP.NET Project itself?
What is the primary purpose of Data Templates in Sitecore?
Are they for developer customization or customer-level customization?
The purpose of a data template in Sitecore is to define the set of fields for content items which inherit from that template. - Think of a data template as a class and the content items (pages) as instances of that class.
Templates are usually used to define the user-editable content of pages within a site, that being said you can have items to store information which is not managed by regular content editors. The question is where do you draw the line between things which should be put into Sitecore and things which should be a part of the solution. My advice is only put things in Sitecore if they need to be there. If you have to have the ability for editors or admins to configure those settings/properties.
I would say that putting SQL/ColumnNames is probably a bad idea unless you are building some sort of report builder interface in which case it may be essential?
Likewise with placing JavaScript into Sitecore; this can be OK in moderation (e.g. snippets of analytics code which content editors may want control over?). If you're placing whole libraries of JavaScript into Sitecore, you're probably doing it wrong.
One final point to note is findability/re-factorability of code: if you have code spread between Sitecore and your solution, it can make it very difficult to maintain as it is difficult to get a complete overview of code involved.

incorporate a html-css template as master page in asp.net- mvc 4

I am building a website, and want to do it using MVC 4. I dont want to use the custom asp.net template, and the asp.net templates available online do not meet my requirements. I have designed a html-css template and need to incorporate it into my project...(pretty much build the "contents folder" of the default templated mvc 4 project myself, if u know what i mean)...
I would really appreciate if someone points me to a tutorial or gives me a step-by-step account of how to do it.
You're pretty much looking for how to use Layouts and Sections with Razor. You can have as many as you'd like.
If I'm understanding correctly, you simply want to apply your template to _Layout.cshtml. This is similar in purpose to a MasterPage in ASP.NET web forms.
Here's a ScottGu blog on layouts and sections. (Just noticed that's the same link provided by #ErikPhilips)
To provide a simple explanation. _Layout.cshtml resides at Project\Views\Shared\_Layout.cshtml. By default it looks like a normal HTML file with a couple of unusual lines. The most important being #RenderBody(). When returning a ViewResult from an action (e.g. return View("MyView, myModel)), your view gets rendered by #RenderBody inside the layout. You can do what you like with _Layout.cshtml and if you're brave, you can also nest layouts.

Something like Smarty in ASP.NET?

Recently, I was working with PHP.
In PHP we have a powerful template engine like Smarty.
Do we have something like Smarty in ASP.NET ?
Quick google search :
Try one of these :)
http://csharp-source.net/open-source/template-engines
Well, you could argue that all ASP.NET webform pages are similar to templates, as they don't need to (and usually don't) have any application logic within the .aspx pages (it all goes in the codebehind). However, you might find that ASP.NET MVC is even more like what you are familiar with. ASP.NET MVC supports a number of view engines, too.
Have you tried Dotliquid?
It's old but still working great with webforms. You can even have User Controls loaded dynamically that use Dotliquid templates to present data from a database or a webapi, giving you the possibility to change the presentation layer by only editing html mixed with Liquid Language (not fully covered).
Check it out at http://dotliquidmarkup.org/try-online
Liquid Documentation at https://shopify.github.io/liquid/

Template system in CodeIgniter like wordpress?

I'm trying to build a template system in CodeIgniter like wordpress. Does anyone have some links or tips to share with me on this matter?
I would like to create several functions that I can call from those php template pages like in wordpress. For example to display the comments from an item or loop through something, or even a tag_could.
the views folder would containt the different template folders & files.
and yes there is smarty, but no I don't want to use it.
Have a look at my Template library. It supports modules, themes, partials and layouts so you can create one main layout for each theme then have modular views if you wish.
While you are not a fan of Smarty, you might be interested in trying Dwoo. They are both very similar but Dwoo has the advantage of not sucking major donkey balls, which is Smarty's main downfall. I have written an extension for the CodeIgniter Parser library to get it to use Dwoo, which integrates perfectly with my Template library.
Between the two you can make pretty powerful, theme-able MVC applications.
Check out
http://www.williamsconcepts.com/ci/codeigniter/libraries/template/index.html
Template is right for you if:
You feel like using views can be clunky, especially when "embedding" views.
You don't like calling header, footer, and other global views from every Controller method.
You prefer having one "master template" that can be changed for any controller in order to meet unique application design needs.
You don't want to drastically alter the way you interface controllers and views.
You like clear, thorough documentation on par with CodeIgniter's User Guide.

Customizing GraffitiCMS

I downloaded GraffitiCMS the other day(now open source and free), and like a lot of what I see, but what I really want to use it for, is to add CMS capabilities to an existing asp.net database/application.
Without getting bogged down with all the details of my app, can someone give me the basic 'approach' that should be taken to add custom content to Graffiti; content that won't be a 'post'?
I've seen for example, how to add custom-widgets to Graffiti - basically inherit from the widget class, compile your dll and plop it into the correct directory and it becomes part of the system. Is there a way to do something similar for the main content areas?
For simplicity sake, pretend I have a non-graffiti database with gig's of data that I want to display on the website using standard asp.net grid's and forms. I realize I could just go in and hack apart the source code to integrate my existing app, but that is likely not the correct approach.
Not looking for a complete solution her, just a pointer and what areas to investigate...thanks.
If you check out the latest source of Graffiti (or the 1.3 branch that was recently created), support was added to put widgets anywhere you want on any page. There is a new chalk function - $macros.Widget - that provides you with this ability. Dan Hounshell wrote a blog post on how you can use this new functionality:
http://danhounshell.com/blog/graffiti-cms-1-3-add-a-widget-anywhere-in-a-view-with-new-widget-macro/
If you're looking for something different than that, just let me know - we're working to make Graffiti even better for situations just like you are currently in.
What we have done to be able to integrate Graffiti CMS with our current ASP.NET projects is to create a post in Graffiti called "hidden" and then with our standard .ASPX pages we call a class in our Render Override that pulls the "hidden" post (ie: site.com/hidden/) and uses the header and footer to wrap the Graffiti theme around our custom .ASPX page. We use some HTML comments in the "hidden" post to be able to parse the header and the footer. It is kind of a hack, but has worked out really well for us.
I think you're trying to put the cart before the horse - depending on the size and amount of functionality, I would be looking to rebuild it after learning the development platform of my CMS system of choice.
I'm pretty much in the same boat right now. I have avoided Graffiti because I have to learn "Chalk" (whatever that is) and Umbraco (using XSLT for layouts is retarded). So far, this leaves me with Sitefinity at the top of my list and Telerik have just pulled the free version!
I may end up grabbing a very basic CMS which is easier to customize. I know this doesn't directly answer your question, but it may give you some food for thought :-)

Resources