Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2009-06-30 18:18:19

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Go to Category section from wherever

First check your code. You have closing tags (p and ul) that are not opened anywhere, and at least one div that isn’t closed; fixing that will probably solve at least part of your problem. Then please post back:

  • what does the code look like now?
  • what does it actually display?
  • what did you want it to display?

Offline

#26 2009-07-01 12:32:04

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

hi Els, ant thankyou for your patience..
I readed some posts around the forum and browsed in the web with google.
I realized perhaps could be a solution using only one section with categories and subcategories.
In fact, returning on the “sweet” example posted somewhere before, if I have all the products in
only one section called “products”, than I make two categories:

category 1 “kindofsweetness”
with children categories like “cakes, puddings,….etc”
category 2 “provenience of it”
with children categories like “The Netherlands, France, United Kingdom,…etc”

to have the navigation menu, on the left side I think I have to put something like this code:

<txp:category_list parent="kindofsweetness" exclude="kindofsweetness"
label="kindofsweetness" sortby="Title ASC" this_section="1" />

<txp:category_list parent="kprovenience of it" exclude="provenience of it"
label="provenience of it" sortby="Title ASC" this_section="1" />

but it doesn’t work; it works only if i have this kind of code:

<txp:category_list parent="kindofsweetness" exclude="kindofsweetness"
label="kindofsweetness" sortby="Title ASC" this_section="1"
active_class="active" type="article" />

<txp:category_list parent="kprovenience of it" exclude="provenience of it"
label="provenience of it" sortby="Title ASC" this_section="1"
active_class="active" type="article" />

(I copied the code from an example somewhere on the web and pasted into my page)
In this way I have a menu like this:

kindofsweetness
cakes
puddings
……..
……..

provenience of it
The Netherlands
France
United Kingdom
……..
……..

selecting a subcategory on the menu, it outputs the list of articles of that subcategory.
this could be good for me at now. but I’d like to understand:

1- why the first part does not work and the second works? (aka what I don’t understand?)
2- I see the list only if I’m in the section “products”. So if I’m in the default section (the HOME one)
it doesn’t show anything. how to solve this problem? Have I to set all things in the default section to avoid this?
3- how to have a permanent color on the “current” category name? I tried adding an active class on the “style” but something is wrong I suppose

#sidebar-1 a:active
{
color: =FF33FF;
color: yellow;
}

it is not permanent

Offline

#27 2009-07-01 19:34:56

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Go to Category section from wherever

Hey, great that you figured this out! As you can see, with Txp there are always many roads that lead to Rome (as we say over here) :)

1- why the first part does not work and the second works? (aka what I don’t understand?)

First: replace sortby with sort (unless you are using a very outdated Txp version, which is not recommended anyway).
Can you define ‘does not work’? What does it do? The only difference between those two tags is that the second one sets an ‘active’ class. type="article" is the default value, so it shouldn’t make a difference at all.
There is a typo (kprovenience), but I don’t know if you only pasted it that way here or if you are really using this on your page. Also, your category name shouldn’t have spaces in it. It should be something like provenience-of-it. But again, you may not be using this very code on your page.
You can also put your site in ‘debug’ mode (Admin > Preferences), and look at the tag trace. If it doesn’t tell you anything you can post it here and I can have a look.

2- I see the list only if I’m in the section “products”. So if I’m in the default section (the HOME one)
it doesn’t show anything. how to solve this problem? Have I to set all things in the default section to avoid this?

Are you using a different page template for your section ‘products’ than for your front page (default section)? If you want the navigation menu to be visible on all pages of your site, you need to place the code on every page template that’s in use. Better: place it in a form named ‘navigation_menu’ and put <txp:output_form form="navigation_menu" /> on every page.

3- how to have a permanent color on the “current” category name? I tried adding an active class on the “style” but something is wrong I suppose

#sidebar-1 a:active

active_class="active" generates class="active" in the html <a> tag when viewing the current category. So you only have to change #sidebar-1 a:active to #sidebar-1 a.active.

Offline

#28 2009-07-02 15:48:05

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

Hi Els! let’s go on:
1- it doesn’t work means that there is NOT menu if I use the first codes; there IS menu (like the one I posted before) if I use the second codes. it seems it works only if there is the active class inside… mmm… I try to clean a bit the code an then I’l retry, and then I’ll post the tag trace if I’ll not understand it
2- I’m using the same form and style and page for all (I’m modifying the default one). It seems I have to be in the specific section to have the menu working.
If I’m in the default section (the homepage), I see the menu but it outputs nothing, showing always the homepage. The menu outputs the articles only if I’m in the “product” page.
If there are no other solutions about this, I think I’ll put every articles in the default section (I don’t see other options off this…)
3- good! this works well, thankyou!!

Offline

#29 2009-07-02 20:02:48

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Go to Category section from wherever

alarius, #2: replace this_section="1" with section="products".

Offline

#30 2009-07-10 11:58:04

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

good, Els! Now I have understood: it’s no possible to have an “automatic” menu, I have to set some fixed parts, as “products” instead of “this_section”.
ok, my little site is going on well now.
This thread will became a complete tutorial in this way… :)

(edit)
… but now my sidebar is becoming really long! so I’m searching a way to have this behaviour:

- on the left have the list only of the parent category;
example:

kindofsweetness

provenience of it

- when I select one of it, appears the child categories
example:

kindofsweetness
cakes
puddings
……..
……..

provenience of it

I say select because I think is too complicate to use :hover feature for this, so is sufficient if it works on mouse click…
But it seems to me even this is so complicate…

Last edited by alarius (2009-07-11 08:05:50)

Offline

#31 2009-07-13 16:52:34

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

hi Els and everyone is interested about this problem…
so, I’m going on but it’s becoming every step more complicate…
now I have a really (too) long list of subcategory on my left side.
as I told you before, could be something good if I can have a compact menu, I’m trying to do it but I’g going crazy..
the result hase to be something like only the two voices on the menu, and “expand” on the click of the mouse, showing the sub categories…
a better thing probably is that I see the first category kindosweetness with all the subcategories (child) listed on the menu,
and the last voice only the link to the second category provenienceofit without subcategories (child) listed.
on click of provenienceofit the behaviour must invert, show only the subcategories of the second and only the link to the first…
hope to be understood!! :) my english is bad sorry…
some help please?

Last edited by alarius (2009-07-13 16:58:56)

Offline

#32 2009-07-14 15:45:51

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

I’m trying to modify this tip
http://txptips.com/drop-down-menu-using-txp-tags
adapting for my problem, but probably I need help :(

Offline

#33 2009-07-14 19:23:20

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Go to Category section from wherever

alarius, I wrote that tip, what help do you need?

Offline

#34 2009-07-15 10:22:05

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

Hi jstubbs! well, I have two parent categories:
kindosweetness
provenienceofit
and a lot of child categories in both of them.
after this I have articles.
What I need is
1: have a left menu with only the two parent categories;
2: by selecting one, it shows the list of the children categories of the selected parent, but It has to appear on the left menu at the bottom of the specific category;
3: by selectin a child category, it show the list of articles of that child category in the content part of the page.

—- example of left side menu with no selection (bold is a link):

kindosweetness

provenienceofit

—- now I click on kindosweetness:

kindosweetness
__ cakes
__ puddings
__ other kind of sweetness

provenienceofit

—- now I click on provenienceofit:

kindosweetness

provenienceofit
__ united states
__ the nederlands
__ france

Offline

#35 2009-07-16 08:41:20

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Go to Category section from wherever

Hi alarius,

Basically you need a script to open/close the child categories. Take a look at this TXP Tip which includes most of what you need.

Don’t have time for more this morning, but it should get you started…

Offline

#36 2009-07-21 16:16:53

alarius
Member
Registered: 2009-05-28
Posts: 45

Re: Go to Category section from wherever

not what I need…
with the code
<txp:category_list parent="kindofsweetness"
exclude="kindofsweetness" label="kind" sort="Title ASC" section="products" active_class="active" type="article" />
</p>
<txp:category_list parent="provenienceofit"
exclude="provenienceofit" label="provenience" sort="Title ASC" section="products" active_class="active" type="article" />
it works good, because it shows on the left side the list of sub-categories of both main categories.
the problem is the length of the menu, so I’m searching help for having on the homepage only two links
to the two parent categories on the left menu, and selecting one category something to output in the left menu
the subcategories of that category.
I suppose I have to code this
<a href="?s=products&c=kindofsweetness">kind</a>
</p>
<a href="?s=products&c=provenienceofit">provenience</a>
but it doesn’t work, I see nothing if I select one of the two links.
probably I have to make two static pages?

Offline

Board footer

Powered by FluxBB