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 on http://demo.satchmoproject.com/ and worked fine.
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
> > > > > > satchmo_currency satchmo_discounts app_plugins normalize_decimal %}
>
> > > > > > Now when I try to go to the site I get an error saying:
>
> > > > > > 'update_category' is not a valid tag library: Template library
> > > > > > update_category not found, tried
>
> > > > > django.templatetags.update_category,satchmo_store.shop.templatetags.update_
> > > > >
> > > > > category,django.contrib.admin.templatetags.update_category,django.contrib.c
> > > > >
> > > > > omments.templatetags.update_category,sorl.thumbnail.templatetags.update_cat
> > > > >
> > > > > egory,livesettings.templatetags.update_category,satchmo_utils.thumbnail.tem
> > > > >
> > > > > platetags.update_category,satchmo_store.contact.templatetags.update_categor
> > > > >
> > > > > y,tax.templatetags.update_category,product.templatetags.update_category,pay
> > > > >
> > > > > ment.templatetags.update_category,payment.modules.giftcertificate.templatet
> > > > >
> > > > > ags.update_category,satchmo_ext.upsell.templatetags.update_category,satchmo
> > > > >
> > > > > _ext.productratings.templatetags.update_category,satchmo_utils.templatetags
> > > > > .update_category,app_plugins.templatetags.update_category
>
> > > > > > What am I doing wrong? Do i need to specify where templatetags live?
> > > > > > and thanks for all the help so far!
> > > > > > RT
>
> > > > > > On Jul 15, 9:51 am, Stuart Laughlin <[email protected]> wrote:
>
> > > > > > > category_tree is a template tag that outputs the HTML in question.
>
> > > > > > > Check "satchmo_store/shop/templatetags/satchmo_category.py" for
> > > > > > > the
> > > > > > > implementation of category_tree.
>
> > > > > > > --Stuart
>
> > > > > > > On Thu, Jul 15, 2010 at 11:40 AM, RT <[email protected]> wrote:
> > > > > > > > Thanks for the help, I am a little bit confused by the way
> > > > > > > > Satchmo
> > > > > > > > works with Django (I'm pretty new to both) so if this is the
> > > > > > > > code
> > > > > > > > which then generates the sidebar as a <ul>:
>
> > > > > > > > <h3>{% trans "Shop Categories" %}</h3>
> > > > > > > > {% 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>
> > > > > > > > How exactly do I use jquery with it? Where is the <ul> coming
> > > > > > > > from?
>
> > > > > > > > On Jul 14, 10:40 am, lzantal <[email protected]> wrote:
> > > > > > > >> Hi,
>
> > > > > > > >> On Jul 14, 10:11 am, RT <[email protected]> wrote:
>
> > > > > > > >> > I have searched a bit and haven't found anything about this.
> > > > > > > >> > Is there
> > > > > > > >> > any easy way to make subcategories collapse into their
> > > > > > > >> > parent category
> > > > > > > >> > and only show when you click the parent (in the left
> > > > > > > >> > navigation of the
> > > > > > > >> > simple store). Has this been implemented or do I need to
> > > > > > > >> > implement it
> > > > > > > >> > myself. Thanks!
>
> > > > > > > >> I use jquery.toggle() to do that. Just wrap the subcategories
> > > > > > > >> in a
> > > > > > > >> div
> > > > > > > >> and bind toggle event to the parent which will show and hide
> > > > > > > >> the
> > > > > > > >> subcategories for you.
>
> > > > > > > >> lzantal
>
> > > > > > > > --
> > > > > > > > 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
> > > > > > > > athttp://groups.google.com/group/satchmo-users?hl=en.
--
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.