asp.net MVC3 ActionResult multiple models and a view - asp.net-mvc-3

What I am trying to do using asp.net MVC3:
-User selects a Category from a list of Categories.
-The SubCategories page then displays a list of images found to represent that Parent Category as well as the list of SubCategories.
I run into the need for multiple models because the "Category Images" are associated with Category and not the "SubCategory model". Yes I realize this seems like it has been asked many times before but the syntax is still foreign to a noob like me. What goes where?
I got the Category -> Html.Actionlink to the controller to return a list of SubCategories part... but even if I did some left join to get category and list of images as well, how would I get those into the same view as the list of subcategories?
Update
Found this posting:
http://francorobles.wordpress.com/2011/05/03/returning-multiple-models-in-1-view-in-asp-net-mvc3/
Question: Is that a valid approach? My intellisense suggests no.

In cases like this you need "view models", i.e. view-specific models that have all the data your view needs.

Related

Processwire Holder/Page implementation

How do you implement a holder/page pattern in Processwire. The idea is simple. One page type manages the list view, and usually contains very little native content. The primary function of this page is to provide a list of its child pages, providing a brief summary for each one, along with a link to its detail view. A second page type will represent the detail view for any given child page, which will typically have a custom template and content fields that make up its identity. Think of it think like a news listings, image galleries, even a Twitter timeline.
I can give examples for two different methods from a recent site I built with Processwire.
First is NEWS section:
I have a page called News and it's template is news-listing. Under News, I have news pages and their template is news-detail. news-listing template only accepts news-detail and news-listing for child pages. I allowed news-listing under news-listing if client needs to create sub listing pages under news.
News-listing template basically gets the news with
<?php $news = $page->children('template=news-detail'); ?>
Second is Products section
Site has different section for purposes. Like WOMENS, MENS, KIDS etc. The products are not shared among those main separation. I have a structure like below
MAIN SEPARATION
Products (products are listed under)
Categories (categories are listed under)
On product details page you can select multiple categories. On categories page products are listed like this. And on main separation page I have categories listed. Each of these page type has their own templates.
$products = $page->rootParent->find("template=product-detail,category={$page->id}");
Hope it helps
Just create pages under parent page then iterate on children pages. Processwire is slow though, better use Silverstripe it's more responsive.

Filter Articles in a categories based on previously clicked Article in another category.

I have a Joomla site with a few branches of categories.
One branch of categories is about brands where the Articles are a presentation of a Brand. Example: Brands->European->German->Mercedes(Article).
Another Branch is about Parts and services where an Article represents one part. Example: Parts->Interior->DashBoard->Odometer(Article).
What I need to do is once I click in an Article Inside the Brands category, lets say "Mercedes", and then go to the Parts branch of categories, I need it to display only the Parts (articles) that are related to the Mercedes Articles.
How can I achieve this?
How can I related one Article from one category branch to another article from another category branch?
How can I than use it as a filter in the Parts Category?
I'm considering other ways of doing this, but this is an website that was given to me like this, with hundreds of categories and articles already set that I only need to filter Parts articles according to Brands Articles previously clicked.

Adding multiple items to special page

I have a quick how to question with Magento.
On my main site I need to have 7 links to special "categories" of items, but these don;t reflect categories of items. It is for a clothes shop so link may be to a summer wear page to only display items tagged as summer wear but from all types of item and categories.
What would the best way to go about creating this functionality?
I am assuming that when you say 'taged' you mean the product has a attribute set to 'summer'. In that case:
If you have products that you want to group together by attribute and list similar to a category page without being in a category, you could try using the Fishpig Splash Page extension:
http://fishpig.co.uk/attribute-splash-pages.html
This extensions allows product attributes to group products instead of categories.
I hope I understood your question correctly.
You can create categories for each of the 7 pages you mention, but hide them from the navigation in the category settings page.
you can then add your products to these categories as you see fit.
They will still be in their original categories too, but you can now link to the new pages and see them there too.
It seems like to me, you would just create the categories like normal. Because products can belong to many categories, you would just assign on a per-product basis which ones need to be in your categories.

Do I need a model or view model? MVC 3

I have a pretty standard scenario where I have a model which in this case is a product.
The product model has a load of properties such as price, desc etc which I want to display on a view.
I have this working fine.
The product has a list of accessories objects which get displayed on the view and gives the user the ability to enter a qty for that accessory.
When the user clicks add to basket I only actually need the list of accessories and the id of the parent product.
Should I be creating a view model that contains all the product info I need or do I just pass my view the product and then on submit just get a view model for the few fields that I need in the signature of the function?
I'm new to mvc in case you hadn't guessed!! and I am using MVC 3.
Using a separate view model is better practice as it means you can add extra information outside of the Product which may be relevant such as Basket and User info. If you have many fields on the product then you can use Automapper to take the relevant fields and map them to the view model. Also you can flatten the model if necessary and make serverside queries which fecth all of the model's related items such as Category info etc.
Take a look at Automapper here:
http://lostechies.com/jimmybogard/2009/01/23/automapper-the-object-object-mapper/
once you start using it you won't look back.
The academic way would be to crete a separate ViewModel class with just the data you need in the view.
But when you are comfortable with ignoring the extra fields in your class i think its absolutely ok to use your Product model class in the view.

Need a creative way to post employee bios

i need to find a creative way to post employee bios.
right now i just have it in a table, alternating bio and pictures, like this:
person 1
[picture] [bio]
person 2
[bio] [picture]
person 3
[picture] [bio]
person 4
[bio] [picture]
its really hard to maintain when i need to add or remove a person.
could anyone suggest an extension i could use for this?
it does not have to use a table, just look good(creative) and be easy to maintain
thank you!
I would suggest the best way would be to create a category for your employees then use a category blog layout with multiple columns. This would give you a nice first page where you could have name+picture, and then upon clicking their name you view an individual page about that person.
Should you choose this solution (I am assuming 1.5). Create a category for employees and create an article for each employee within this category. Seperate the photo from the main content using the "read more" button.
Then goto menus->main menu->"new"
The type you want to select is articles -> category -> category blog layout.
On the next page, pick the category you created earlier on the RH side, and just below that you can specify how many columns and how many employees to view per page.
Hope this helps, the same method loosely applies to Joomla 1.6, however, categories are setup differently.
I found a solution - DJCatalog Extension did the trick :)

Resources