Inhalte aufrufen

Profilbild

how to use 2 model in a views (not use controller, not edit model).


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
5 Antworten zu diesem Thema

#1 Xuan Can

Xuan Can

    Member

  • Members
  • PunktPunkt
  • 11 Beiträge

Geschrieben: 14 July 2016 - 10:53

i'm designing a new theme and i want to move (shopping cart, wish list, account) from shopbar (Shopbar.cshtml) into menu (Menu.cshtml) but i can't use 2 model (ShopbarModel & MenuModel) in View Menu.cshtml.
 
Please help me.
Thanks you!


#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 14 July 2016 - 11:38

In the action method you can pass a reference of the second (third etc.) model through ViewBag or ViewData into your view.
Or you can use the property "CustomProperties" of the first (main) model to pass any extra data into your view.

Marcus Gesing

Smartstore AG


#3 Xuan Can

Xuan Can

    Member

  • Members
  • PunktPunkt
  • 11 Beiträge

Geschrieben: 15 July 2016 - 03:30

 

In the action method you can pass a reference of the second (third etc.) model through ViewBag or ViewData into your view.
Or you can use the property "CustomProperties" of the first (main) model to pass any extra data into your view.

 

 

thanks for your answer. but all of them need edited on Controller or Model. While i designing, I only changed on View. Is there any way use 2 model on a view just edit Viewer?

Ty.



#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 15 July 2016 - 11:42

No, not by only changing the view. That would conflict MVC architectural pattern by the way.


Marcus Gesing

Smartstore AG


#5 Xuan Can

Xuan Can

    Member

  • Members
  • PunktPunkt
  • 11 Beiträge

Geschrieben: 22 July 2016 - 10:32

Thanks you. i'm writing new shopbar, but Shopping cart not update quantity and list of product when i click Add to cart. please tell me why?



#6 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 22 July 2016 - 12:04

Shopbar infos are updated through public.shopbar.js, method loadSummary. Probably your new HTML does not use the expected id and class names like "shopbar-button".


Marcus Gesing

Smartstore AG