Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2009-06-26 20:19:44
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Go to Category section from wherever
Ah thank you, now it all makes sense to me :) No, I don’t think you’ll need a plugin, this looks like a perfectly logical use of Txp. I’ll think of something and post back.
Offline
#17 2009-06-26 20:59:07
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Go to Category section from wherever
OK, here’s how I would do it. Create a section ‘countries’ that you can use to display the articles sorted by country, it can use the same page as your other sections are using. This section will have no articles in it.
This is your navigation menu on the left:
<ul>
<txp:section_list exclude="countries" wraptag="" break="li" />
<li><txp:section name="countries">Show me countries</txp:section></li>
</ul>
The code for the content part of the page (on the page template(s) used for your section pages) can be something like this:
<txp:if_section name="countries">
<h2>Desserts by country</h2>
<txp:category_list sort="title" break="">
<h3><txp:category title="1" /></h3>
<txp:article_custom category='<txp:category />' sort="Title asc" limit="999" wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:category_list>
<txp:else />
<txp:if_article_list>
<h2><txp:section title="1" /></h2>
</txp:if_article_list>
<txp:article form="your-individual-article-form" listform="your-article-list-form" sort="Title asc" limit="999" />
</txp:if_section>
Offline
#18 2009-06-26 22:02:05
- alarius
- Member
- Registered: 2009-05-28
- Posts: 45
Re: Go to Category section from wherever
sorry Els my example was not good to explain my doubt.
let’s start from the beginnig:
I’ve textpattern like is installed.
I explain with a musical example, a site with only one article for every one artist.
what I need is a main page with the menu on the left where I have:
classical
rock
punk
….
provenience
so, when I select classical, I want to see in the content of site a linkable list of classical artist
so, when I select rock, I want to see in the content of site a linkable list of rock artist
so, when I select punk, I want to see in the content of site a linkable list of punk artist
but if I select “provenience” I’d like to see a list like this:
classical
- mozart
- chopin
- ………
rock
- Eagles
- Fleetwood Mac
- ………
punk
- greenday
- bad religion
- ………
could you explain me how to obtain this modifying the textpattern default models (page/form)?
thnakyou for the patience, if you still have…
Offline
#19 2009-06-26 22:34:20
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Go to Category section from wherever
So it’s not using categories now? Rock, punk etcetera are sections?
Offline
#20 2009-06-26 22:47:06
- alarius
- Member
- Registered: 2009-05-28
- Posts: 45
Re: Go to Category section from wherever
I’m asking you what is the best and simplest way to obtain that lists, so please tell me if I have to use category or section or both
edit:
example, I’m using this part for the page:
<!— left —> <div id=“sidebar-1”> <txp:section_list default_title=’<txp:text item=“home” />’ include_default=“1” wraptag=“ul” break=“li”> <txp:if_section name=’<txp:section />’>»</txp:if_section> <txp:section link=“1” title=“1” /> <txp:if_section name=’<txp:section />’> <txp:article_custom section=’<txp:section />’ wraptag=“ul” break=“li”> <txp:if_article_id>›</txp:if_article_id> <txp:permlink><txp:title /></txp:permlink> </txp:article_custom> </txp:if_section> </txp:section_list> <txp:search_input wraptag=“p” />
</div>
but it shows me the list on the left menu (as submenu) and the plain articles on the content.
i want the menu remains the same (only higlight with active class) and on the content the list
Last edited by alarius (2009-06-26 23:20:52)
Offline
#21 2009-06-26 23:18:04
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Go to Category section from wherever
In your last example you won’t need both sections and categories, so let’s use sections. Using the default Txp installation you can follow these steps:
First create your sections (classical, punk, etcetera), and a section ‘provenience’. Let’s keep it simple and have all your sections use page ‘default’.
Write your articles (don’t put articles in section ‘provenience’).
You can use the existing forms ‘single’ and ‘article_listing’, but if you don’t want to display the posted date with the articles, remove · <span class="published"><txp:posted format="%Y-%m-%d" /></span> in ‘article_listing’ and <p class="published"><txp:posted /></p> in ‘single’.
On page template ‘default’, replace the entire <txp:section_list>...</txp:section_list> part (in sidebar-1) with this:
<ul>
<txp:section_list exclude="provenience" wraptag="" break="li" />
<li><txp:section name="provenience" title="1" link="1" /></li>
</ul>
In the ‘content’ part of the page, replace <txp:article listform="article_listing" limit="5" /> with:
<txp:if_section>
<txp:if_section name="provenience">
<txp:section_list sort="title" break="">
<h3><txp:section title="1" /></h3>
<txp:article_custom section='<txp:section />' sort="Title asc" limit="999" wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:section_list>
<txp:else />
<txp:article form="single" listform="article_listing" sort="Title asc" limit="999" />
</txp:if_section>
<txp:else />
This is your front page. I don't know what you want to display here.
</txp:if_section>
Offline
#22 2009-06-26 23:39:49
- alarius
- Member
- Registered: 2009-05-28
- Posts: 45
Re: Go to Category section from wherever
ok,-this seems to work at the moment.
but i have still the submenu in the menu, and I want the same menu everywhere in the site.
after this, how to configure “provenience” to set the article as I told before?
too late for me now, I’m tired and not sure what I’m dooing…
I’l try it better tomorrow.
thankyou for the moment!
Last edited by alarius (2009-06-26 23:43:37)
Offline
#23 2009-06-29 11:03:30
- alarius
- Member
- Registered: 2009-05-28
- Posts: 45
Re: Go to Category section from wherever
there is something doesn’t work as I want…
i made some changes, and I have now this code:
<div id="sidebar-1">
<txp:section_list sort="title asc" default_title='<txp:text item="home" />' include_default="1" exclude="provenience"
wraptag="ul" break="li">
<txp:if_section name='<txp:section />'>»</txp:if_section>
<txp:section link="1" title="1" />
<txp:if_section name='<txp:section />'>
<txp:article_custom section='<txp:section />' wraptag="ul" break="li">
<txp:if_article_id>›</txp:if_article_id>
</p>
</txp:article_custom>
</txp:if_section>
</txp:section_list>
</div>
<!-- right -->
<div id="sidebar-2">
<txp:category_list label="Categories" sort="title asc" this_section="0" type="article" />
</ul>
<!-- center -->
<div id="content">
<txp:if_article_list><h1><txp:section title="1" /></h1></txp:if_article_list>
<div class="hfeed">
<txp:article listform="article_listing" limit="5" />
</div>
<txp:if_individual_article>
<div class="divider"><img src="<txp:site_url />images/1.gif" width="400" height="1" alt="---" title="" /></div>
<p><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev>
<txp:link_to_next><txp:next_title /> »</txp:link_to_next></p>
<txp:else />
<p><txp:older>« <txp:text item="older" /></txp:older>
<txp:newer><txp:text item="newer" /> »</txp:newer></p>
</txp:if_individual_article>
</div>
the problem is that now I have my menu on the left, working but not at all (it outputs the “list” of the section on the central part, but the menu takes one white “space” after the current section and the next for every one article, so if section 2 has 3 articles the menu became like this:
section1
section2
__________(white space)
__________(white space)
__________(white space)
section3
and this is no good,I’d like the menu remain the same every time.
on the right menu I have the list of category but it seems not work at the time…
if i put
this_section="0"
it goes on home page any “category” i select.
if I put
this_section="1"
it outputs that category in the current section.
so if it’s possible, id like to view all articles of all sections about one category.
if it’s no possible, I’ll keep with the value “1”, but I’d like at least have both the “current“section and the “current” category higlighted, for example with a yellow background.
at this time only the current section is evident with the symbol “>>”, but I’m searching the way to remove that simbol (I thing is ») and have the yellow background…
(edit: How do I post tags and code on the forum? -Els)
(edit: sorry Els, it seemed to me it was correctly viewed -alarius)
Last edited by alarius (2009-06-30 08:36:48)
Offline
#24 2009-06-30 10:40:43
- alarius
- Member
- Registered: 2009-05-28
- Posts: 45
Re: Go to Category section from wherever
I think my “musical” example was in fact not what I need,
probably I was really tired that night, so please clear about it and let’s try to find a solution for the last post…
there is something wron on my code, or probably I have not understood well how txp works.
if I have three articles on section 2, when I select section 2,
it outputs the list with links of the three articols in the content part of the page
(and this IS what I want)
but the menu seems to be influenced by the number of articles, and in fact the menu expands out of three lines
(and thi is NOT good for me, I need the menu “compact”)
some help? (and sorry again)
Offline
#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