I'm using Orchard CMS and want to be able to show sharing links (think AddThis.com or Shareaholic.com) to blog posts on a website.
Before I start I realise there is a similar modules already present in the Orchard gallery but a, I couldn't get the module to work and b, I'd like to further my understanding of Orchard.
My thought originally was simply to add a new blog widget layer and to add a new HTML widget that contains the aforementioned sharing code. Trouble with this approach was;
The layer rule would force all of my blog pages to have to be under some common url i.e. using a layer rule of something like the following. Not necessarily a bad thing but something that could be missed when the client publishes a new post.
url("~/blog*")
The sharing code contains empty html anchor elements that were getting stripped from the html when I saved in the Orchard editor.
I think #2 is down to the template used in my theme. I read a post from Bertrand Le Roy's blog about overriding templates which got me thinking. Can I just override the Orchard blog template and place the sharing code in there directly? Clearly this is less customisable in the future but I'm happy with that. I'm also thinking having fewer layers, moduels, widgets or whatever can't be a bad thing when considering Orchard performance and load times. I'd also now have my sharing icons on every blog post wherever it may be on the site.
Question is what is the view that I should override in this case? I tried editing the blog views in Modules\Orchard.Blogs\Views expecting to see some changes but I got nothing.
What would people suggest as the best way forward?
The best approach IMHO is to add the code in one of two (or both) templates:
Content-BlogPost.Summary.cshtml when the blog post is shown in a list (you can copy the code from /Core/Contents/Views/Content.Summary.cshtml) and
Content-BlogPost.Detail.cshtml when the blog post is shown in a separate page (you can copy the code from /Core/Contents/Views/Content.cshtml)
Related
We are now in the process of rebuilding some legacy WebForm apps using MVC 5. For one in particular the entire site is dynamic and built from returning a lot of markup from a back-end database, and that markup is different based on the domain name returned...
I got to the first stage of this one (the others not so difficult), building a dynamic menu and started scratching my head (and a few other body parts). In WebForms it was easy, MasterPage and code-behind, done and dusted...
After spending most of the day Googling I gather creating a Base Controller is the way to go... But there seems to be very little material showing how this can be achieved... What is out there is followed by a plethora of comments about how the author has got it all wrong and is direct violation of the MVC pattern...
Therefore, the question is, can someone provide a link to some documentation about how I can add a dynamic menu to a _Layout?
Thanks
I've just finished going through my first book learning RoR and wanted to practice some more extending the project, but I'm at a bit of a loss for how to structure the additions I want to make and would appreciate some guidance.
Right now the application is separated by pages that have a model controlling the logic and a controller routing that logic to the view, but none of the pages have any cross-over in features. I want to create a page that has pre-templated features with logic from other models, sort of like widgets in WordPress, or plugins in Magento. If I had a Page model and wanted to inject a Bestsellers list in the view, or I had a Blog model and wanted to inject a list of products with a tag calling out to a template with all the markup already, what is the proper way to do this?
Would these have to be modules? Would I just create another view template for Catalog that I would call into the Page index view?
Nevermind, I found the answer to what I was looking for here
I am a little ashamed for asking so many questions, but I really want to learn.
In Sipke's blog a webshop is created. There is one specific question that boggles my mind when trying to do something similar.
Let me spell out the basic requirements:
User registration form and login, etc. This one is covered by the blog and it works nice.
Creating product parts and so on. This one is covered and no problem there.
Ordering by filling in an order form and making the payment. See down
Having the order page maintainable by customer. See down.
Viewing your own orders and their status. See down
Maintaining customers and orders from backend system. This one is covered by the blog and I need to do some work there yet.
As for items regarding creating orders and viewing your orders. I have followed the approach for creating records and using standard MVC controllers. But then I encountered problems:
Menu for orders page. This I had to do manually after installing the module.
The order page itself. I had to create the view including title and so on. But I can imagine a customer wanting the order page on another menu and with a different title. And maybe add even some own content to the ordering page. This I couldn't achieve by using standard MVC approach. So maybe I am using the wrong approach here. So I was thinking about using contentparts for creating an order and displaying them and using the drivers and handlers for that. But before I go down that road and refactor everything I want to know if that is the right approach. A downside could be that once the module follows that route it can then not so easily be reused with customers that have other cms's capable of hosting an MVC3 module.
So when to use drivers, handlers and contentparts and when to use standard controllers and views.
You should use Drivers and Parts (with Handlers if needed) when you want to create functionality for content items. E.g. if you want to display a custom media with all products, you could create a Part (together with its Driver, etc.) to handle that. Read the docs on Parts.
If the functionality is not tied to content items the most possibly you want to use the standard MVC toolbox, it's fine. Look at the built-in modules how they do that. E.g. the Blog module uses controllers and views to show the admin UI, but has parts to enhance the functionality of for example the Blog content type.
To make things more complicated you can employ ad-hoc content items to build a page that you'd normally do with simple views, but that's an advanced topic :-).
I've been reading mako / pylons documentation and am having trouble finding good examples / discussion of integrating multiple applications into a single page, so for example, if i had a blog application and an application which just selects a random quotation from a database of awesome quotations. (the example is trivial, just for exposition)
So I want to make a single page which displays both applications,
I'm not sure how to go about writing the templates, i've seen next.body(), do I need to call the controller from the application in a template?
How could I do this on the fly?
Can I just make a model describing the page, and have each application it wants to call as objets in the attributes of the model?
I'm just spitballing here, hoping for a pointer to an example / tutorial i can look over.
Thanks for any advice.
In Django, "applications" are components you develop or choose, then customize, mix and match together to get your final website.
In Pylons, "application" refers to the whole thing you're creating--controllers, models, templates, middlewares, any helper modules, documentation etc. A Pylons application is a bunch of code that can be served as-is by Paster, Apache/mod_wsgi or any other WSGI-supporting web server.
In Pylons, to get, for example, blog posts and random quotations in single page, you'd:
Create separate models for representing and manipulating blog entries and quotes, like myapp.model.Post, myapp.model.Quotation.
Create a controller action that queries models to get X blog posts and a single quotation, put them in data object that will be passed to template.
Create a template that displays both blog posts and quotation on single page. This template can, of course, inherit from some base template or include template fragments, so you don't have to copy-paste common HTML code across many templates.
Hope this helps!
About a week ago I saw a blog post describing how you could write a set of shared Views in the Views/Shared folder that could be used by all your Models. The post also explained how to decorate the Model properties with validation rules and messages. There was information about the new Model Binding improvements. The examples take advantage of new functionality in the preview release of ASP.Net MVC 2.
For the life of me, I can't find the blog post or other information on how to create the shared views.
Can anyone offer a pointer to the post?
Ask and you shall receive.
I've been playing with this quite a bit in the past few days. In addition to generic, dynamic display of editors, details, etc., I've also implemented generic, dynamic modification of data. Essentially, Phil's sample project covers the GET side of things, and I've implemented the POST. I'm also looking into dynamically generating JavaScript in order to have a dynamic list using jqGrid. Stay tuned to my blog if you're interested in this sort of thing.