2011-10-18 3 views
0

저는 django-lfs를 처음 사용했습니다.django-lfs 제품 템플릿

나는 내 요구를 해결하는 상점을 짓기 위해 노력하고 있습니다. 해결할 수없는 문제가 발생했습니다.

제품보기 (카탈로그/제품/인라인)에서이 페이지에 액세스 할 수있는 범주에 액세스해야합니다. 빵 부스러기가 표시되면 그것을 볼 수 있습니다. 예 : 홈> 카테고리 1> 제품 1 하지만 데이터를 사용할 수 있도록 "카테고리"개체에 액세스 할 수 없습니다.

나를 도울 수있는 사람이 있습니까? 사전

+0

내 메뉴를 생성하는 템플릿 태그를 사용하여 관리했습니다.
내가 처음에 원했던 금액은 아니지만 ...
sandok

답변

0

에서

덕분에 내가이 템플릿 태그를 추가 관리했습니다 ...
하지 exacly 무엇인지 잘 작동 wanted..but 전.

@register.inclusion_tag('tagging/lateral_menu.html', takes_context=True) 
def lateral_menu(context): 
    object = context.get("category") or context.get("product") 

if object.__class__.__name__.lower() == "product": 
    request = context.get("request") 
    category=lfs.catalog.utils.get_current_product_category(request, object) 
else: 
    category = object 

top_category=category 
while top_category.parent is not None: 
    top_category = category.parent 

categories =top_category.get_all_children() 
return {"category" :category, "top_category" : top_category, "categories" : categories } 

그런 다음 템플릿에서 필요한 모든 데이터를 얻을 수 있습니다.