Hi Alex,

No problem, glad it worked. :)

lzantal



On Aug 9, 3:24 pm, Alex Liu <[email protected]> wrote:
> Izantal,
>
> Thank you so much. That worked perfectly.
>
> Your help is greatly appreciated.
>
> -Alex
>
> On Aug 9, 4:45 pm, lzantal <[email protected]> wrote:
>
> > Hi,
>
> > Try it with this. It just binds the toggle to the <a> instead of the
> > containing <li>
> > """
> > $("#menu_container li ul").each(function(){
> >   var that = this;
> >   $(this).hide();
> >   $(this).prev().toggle(function(){  $(that).show(); }, function(){
> > $(that).hide(); });})
>
> > """
> > As you see the only thing changed is I replaced the ".parent()" with
> > ".prev()"
>
> > Hope it helps
>
> > lzantal
>
> > On Aug 9, 1:02 pm, Alex Liu <[email protected]> wrote:
>
> > > Hello,
>
> > > I put that script in my base.html file like so:
>
> > >                         {% block sidebar-categories %}
> > >                         <div id="menu_container">
> > >                 {% if category.id %}
> > >                     {% category_tree category.id %}
> > >                 {% else %}
>
> > >                     {% if product.get_category %}
> > >                         {% category_tree product.get_category.id %}
> > >                     {% else %}
> > >                         {% category_tree %}
> > >                     {% endif %}
> > >                 {% endif %}
>
> > >                         </div>
> > >                 <script>
> > >                 $("#menu_container li ul").each(function(){
> > >                 var that = this;
> > >                 $(this).hide();
> > >                 $(this).parent().toggle(function(){ $(that).show(); }, 
> > > function()
> > > { $
> > >                 (that).hide(); });
> > >                 })
> > >                 </script>
> > >                         {% endblock sidebar-categories %}
>
> > > The initial outcome is exactly what I wanted.
>
> > > Now the problem is that whenever I click the last level of the
> > > category tree, it hides it again rather than direct to the category
> > > page.
> > > Category Tree is set like Category -->  Brand Category --> Category
> > > where my products are.
>
> > > If you need to see a graphical example of what the problem is, 
> > > visitwww.robertmillerassoc.com.
> > > On the left sidebar, click industrial pumps --> SHURflo --> 8000
> > > Series VDC Pumps (this is the one I want to actually be click-able)
>
> > > Thanks
>
> > > -Alex
>
> > > On Aug 9, 2:27 pm, lzantal <[email protected]> wrote:
>
> > > > Hi,
>
> > > > Sorry for the late reply.
> > > > Here is a quick way to hide the subcategories.
> > > > """
> > > > $("#menu_container li ul").each(function(){
> > > >   var that = this;
> > > >   $(this).hide();
> > > >   $(this).parent().toggle(function(){ $(that).show(); }, function(){ $
> > > > (that).hide(); });})
>
> > > > """
> > > > I just run it onhttp://demo.satchmoproject.com/andworkedfine.
>
> > > > lzantal
>
> > > > On Aug 8, 7:20 pm, Alex Liu <[email protected]> wrote:
>
> > > > > I looked at the JQuery plugin and did everything I had to for the
> > > > > <head> tag in my base.html file.
> > > > > Now I'm just confused on how to change the rest of the base.html file
> > > > > to specify which categories are span class="folder" and which are span
> > > > > class="file"
>
> > > > >     <div id="leftnav">
> > > > >                 {% block sidebar-secondary %}
> > > > >                 <div>
> > > > >                         {% block sidebar %}
> > > > >                 <b>{% trans "Categories" %} </b>
> > > > >                         {% block sidebar-categories %}
> > > > >                         <div id="menu_container">
> > > > >                 {% if category.id %}
> > > > >                     {% category_tree category.id %}
> > > > >                 {% else %}
>
> > > > >                     {% if product.get_category %}
> > > > >                         {% category_tree product.get_category.id %}
> > > > >                     {% else %}
> > > > >                         {% category_tree %}
> > > > >                     {% endif %}
> > > > >                 {% endif %}
>
> > > > >                         </div>
> > > > >                         {% endblock sidebar-categories %}
>
> > > > >                         {% block sidebar-secondary-bottom %}
> > > > >                         {% plugin_point "sidebar_secondary_bottom" %}
> > > > >                         {% endblock %}
> > > > >                         {% endblock sidebar %}
> > > > >                 </div>
> > > > >                 {% endblock sidebar-secondary %}
> > > > >         </div>
>
> > > > > This is the code in my base.html file for the categories sidebar.
> > > > > I want to uncollapse/collpase categories when I click on them. That
> > > > > is, until I reach the category where all my products are located. Then
> > > > > I want to display the category.html page upon mouse click. Where do I
> > > > > put <span class="folder"> </span>...etc tags? Or do I have to edit the
> > > > > templatetag, satchmo_category.py?
>
> > > > > Is what I'm trying to do possible in a simple manner?
>
> > > > > If not, is there a way to disable links (remove a href) for categories
> > > > > that are not needed?
>
> > > > > Thanks
>
> > > > > -Alex
>
> > > > > On Aug 8, 8:07 pm, Brian Lee <[email protected]> wrote:
>
> > > > > > Check out jQuery plugin called Treeview
> > > > > > Here's a site that uses the pluginhttp://goo.gl/gKEP
>
> > > > > > Brian
>
> > > > > > On Aug 8, 8:03 pm, Alex Liu <[email protected]> wrote:
>
> > > > > > > Dear RT,
>
> > > > > > > Did you end up getting this to work? I'm looking for something 
> > > > > > > similar
> > > > > > > to this and this was the closest thread I found to helping me 
> > > > > > > out. I
> > > > > > > tried to setup JQuery toggle but that ended up not working 
> > > > > > > whatsoever
> > > > > > > so I scrapped my changes and now am back to where I started.
>
> > > > > > > Or if anyone else can help out, it would be greatly appreciated
>
> > > > > > > -Alex
>
> > > > > > > On Jul 20, 11:24 am, RT <[email protected]> wrote:
>
> > > > > > > > Sorry its been awhile since I replied, but here is the vanilla
> > > > > > > > category tag code:
>
> > > > > > > > def category_tree(id=None):
> > > > > > > >     """
> > > > > > > >     Creates an unnumbered list of the categories.
>
> > > > > > > >     Example::
>
> > > > > > > >         <ul>
> > > > > > > >             <li>Books
> > > > > > > >                 <ul>
> > > > > > > >                 <li>Science Fiction
> > > > > > > >                     <ul>
> > > > > > > >                     <li>Space stories</li>
> > > > > > > >                     <li>Robot stories</li>
> > > > > > > >                     </ul>
> > > > > > > >                 </li>
> > > > > > > >                 <li>Non-fiction</li>
> > > > > > > >                 </ul>
> > > > > > > >         </ul>
> > > > > > > >     """
> > > > > > > >     active_cat = None
> > > > > > > >     if id:
> > > > > > > >         try:
> > > > > > > >             active_cat = Category.objects.active().get(id=id)
> > > > > > > >         except Category.DoesNotExist:
> > > > > > > >             active_cat = None
> > > > > > > >     # We call the category on every page so we will cache
> > > > > > > >     # The actual structure to save db hits
> > > > > > > >     current_site = Site.objects.get_current()
> > > > > > > >     cache_key = "cat-%s" % current_site.id
> > > > > > > >     existing_tree = cache.get(cache_key, None)
> > > > > > > >     if existing_tree is None:
> > > > > > > >         root = Element("ul")
> > > > > > > >         for cats in Category.objects.root_categories():
> > > > > > > >             recurse_for_children(cats, root, active_cat)
> > > > > > > >         existing_tree = root
> > > > > > > >         cache.set(cache_key, existing_tree)
> > > > > > > >     # If we have an active cat, search through and identify it
> > > > > > > >     # This search is less expensive than the multiple db calls
> > > > > > > >     if active_cat:
> > > > > > > >         active_cat_id = "category-%s" % active_cat.id
> > > > > > > >         for li in existing_tree.getiterator("li"):
> > > > > > > >             if li.attrib["id"] == active_cat_id:
> > > > > > > >                 link = li.find("a")
> > > > > > > >                 link.attrib["class"] = "current"
> > > > > > > >                 break
> > > > > > > >     return tostring(existing_tree, 'utf-8')
>
> > > > > > > > Thanks for all the help.
>
> > > > > > > > On Jul 15, 4:44 pm, lzantal <[email protected]> wrote:
>
> > > > > > > > > Hi,
>
> > > > > > > > > Make sure the templatetags is a package, so it needs a 
> > > > > > > > > __init__.py,
> > > > > > > > > Also you don't need a custom category tag if all you want is 
> > > > > > > > > collapse
> > > > > > > > > the subcategories.
> > > > > > > > > You just need to would iterate through the category list with 
> > > > > > > > > jQuery.
> > > > > > > > > Could you post the generated html so I can write up a simple 
> > > > > > > > > example?
> > > > > > > > > All my category template tags are modified so I don't have a 
> > > > > > > > > vanilla
> > > > > > > > > satchmo category template tag.
>
> > > > > > > > > lzantal
>
> > > > > > > > > On Jul 15, 11:19 am, RT <[email protected]> wrote:> Where are 
> > > > > > > > > custom templatetags supposed to live?  I put it in store/
> > > > > > > > > > localsite/templatetags/update_category.py (store is the top 
> > > > > > > > > > directory
> > > > > > > > > > of the store)
> > > > > > > > > > Then I changed the top of base.html to look like this:
> > > > > > > > > > {% load i18n update_category satchmo_google satchmo_util
>
> ...
>
> read more »

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to