Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-03-16 14:51:23
- dandul
- Member
- From: Brisbane, Australia
- Registered: 2010-01-31
- Posts: 33
Go straight to category articles in another section
I want to have a link on my homepage that goes to a section, and displays all the articles from a category in that section, using a form to create a small intro article.
So – for example – if someone clicks on the “weanlings” link on the hompeage, they will be taken straight to a page in the “female alpacca” section that will display the title, picture and intro text from all the articles in that section in the category “weanlings”.
At the moment the best I’ve done is have the link go to an article in the “female alpacca” section. In the article is a tag that that then generates the category list and displays the intro article.
<txp:article_custom form="sa_brief_sales" category="weanlings" wraptag="ul" break="li" />
It’s a bit cumbersome, and I was wondering if some kind soul knew a better way of doing it. Or a plug-in that streamlined the whole thing?
Stop wishing things were different to the way they are. Accept it, deal with it, move on.
Offline
Re: Go straight to category articles in another section
have you tried to make the link like this: http://yoursite.com/yoursection/?c=weanlings
and put in your code <txp:article wraptag=“ul” break=“li” />
The link above tel txp to show articles in category weanlings using the section yoursection (i think “female alpacca” is a title of your section but in the link you must use the name of the section instead).
Cheers
Offline
Re: Go straight to category articles in another section
Standard Textpattern logic is that categories are not section bound.
Basically you should use sections for your goal to achieve easy & complete partitioning (!) of your content. But do you really want that? The question to ask if you want to start a new section is: Is that content really different? Is that content really worth it’s own & separate listing (or design)?
I’ll present you a simple solution but maybe you will consider a different navigation concept after understanding the architecture.
The basics are covered best in this old masterpiece: Textpattern Semantics
More on Categories vs. Sections
It would seem that most people confuse the roles of Categories and Sections, the common error being to treat Categories as a navigational structure. A person with this mentality is going to have a hard time understanding what sections are for.
Sections fence off articles into discrete bunches, totally separate from each other. A Category is nothing more than a label you put on an article. They are used for sorting information within a section.
Within a section you can display:
* all articles for that section, or * only articles of certain categories, but still, only articles that are in that section. (Exception: with the new <txp:article_custom /> tag, you can direct Textpattern to display articles from other sections. However, the normal <txp:article /> tag will only show articles in the current section as described above.)
This should also explain why Textpattern does not paginate across sections.
Categories are universal and not tied to sections at all; If you have a “Musings” category, you can assign it to any article no matter what section it’s in. Again, this is because categories and sections are under two separate hierarchies.
To restrict the category list output to a section is of course possible in TXP :)
Solution 1 – Check out: textbook.textpattern.net/wiki/index.php?title=category
section=“section name” Restricts category search to named section. Default: current section (for backwards compatibility).
I am not sure if multiple sections as in section="section name1, section name2"
are allowed.
Solution 2 – Get the plug-in tru_tags
and use tags aka keywords to output lists for certain content.
To use keywords is IMHO the best & most flexible solution to ‘tag’ articles.
More info about understanding the section/category issue:
From the semantic model (Pls. check the ‘Related reading:’ links)
Categories Categories are a method of organizing articles by the nature of their content – not by their location in the navigation structure. If you cut articles out of the newspaper and put them in envelopes, you’d be matching the effect of categories. You may have an envelope for Britney Spears that had an article from the “entertainment” section and maybe an article from the “birth announcement” section. The Britney Spears Category is nothing but a label that was put on Articles to make it easier to search and display information. Categories are not intended to be used as navigational elements.
From the sections admin help page
Sections are the principle content organization mechanism in Textpattern, and the Sections panel is where you manage them (Figure 1).
Sections essentially provide the ability to create lateral structure in your site, thus each section has its own unique URL if the site is configured to use clean URLs in Basic Preferences.
Last edited by merz1 (2010-03-16 15:57:11)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: Go straight to category articles in another section
Second answer Let’s analyze what you want.
I want to have a link on my homepage that goes to a section, and displays all the articles from a category in that section, using a form to create a small intro article.
- Fix link to a pre-defined category in a specific section?
- Answer: Solution 1
- A small intro article for that category article list in a specific section.
- Answer: Here the mix of two hierarchies, sections and categories, starts to become difficult. You need a list of
txp:if_category
conditions to show different sticky articles depending on the category (category1 or category2). This is not very elegant.
- Answer: Here the mix of two hierarchies, sections and categories, starts to become difficult. You need a list of
Beside ‘elegance’ the point is that multi-level navigation inside core Textpattern is only, hm, basic (like no sub-sections aka a section inside a section). There are multiple plug-ins – search for ‘navigation’ – which offer ways around that, but for a beginner I would recommend to start with the core features plus only a minimum of plug-ins.
Again, IMHO, I would use tru_tags which is worth to use anyway.
Take the time to read trutags-usage-instructions. For your case tru_tags_if_tag_search is very important because here you can use raw HTML, article_custom
or output_form
inside multiple if/else conditions to create a generic or an individual output above each tag search result list.
By using nested tagging as below you can automate the first step of the if/else process in the tag section page template:
<txp:tru_tags_if_tag_search tag='<txp:tru_tags_tag_parameter />'>
<!-- tag parsing inside tag through single quotes! -->
<!-- Nested tags not tested in my tru_tags installations! -->
<txp:output_form form='intro-<txp:tru_tags_tag_parameter />'>
<!-- Should die gracefully aka 'no output' if form does not exist -->
<!-- tag parsing inside tag through single quotes to call appropriate form!
'appropriate form' can contain plain HTML or loads of TXP code -->
<txp:else />
<txp:tru_tags_cloud />
<!-- This happens if on the /tag/ page aka 'no tag search result page'. -->
</txp:tru_tags_if_tag_search>
The basic hint is to stay inside one hierarchy (section, category, keyword) and not to mix them up. The results are: Better performance, cleaner semantics & better understanding of the if/else conditions :)
Last edited by merz1 (2010-03-16 16:48:33)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#5 2010-03-17 11:35:34
- dandul
- Member
- From: Brisbane, Australia
- Registered: 2010-01-31
- Posts: 33
Re: Go straight to category articles in another section
Thanks Merzi, I appreciate the comprehensive reply! I agree mixing categories and sections isn’t a good idea, and hopefully as I learn more about Textpattern I can work with the logic, not around it.
Having said that I’m going to use Dragondz’s suggestion because it works with the set up I’ve got. The alternative is a complete rewrite and I’m not up to that.
Thanks for both replies, helpful as always
Stop wishing things were different to the way they are. Accept it, deal with it, move on.
Offline
Re: Go straight to category articles in another section
Well, thanks for the task to think around the standard Textpattern logic. Good luck :)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#7 2010-03-18 16:14:43
- sereal
- Member
- From: Indonesia
- Registered: 2010-02-18
- Posts: 55
Re: Go straight to category articles in another section
thank you..this posts help me a lot !
$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?
Offline
Re: Go straight to category articles in another section
@dandul If you want a direct link to (1.) a section followed by (2.) a category filter I would use the TXP syntax for “Solution 1 – Check out: textbook.textpattern.net/wiki/index.php?title=category”:
<txp:category section="section name" name="category name" link="1" title="1" />
It is much cleaner & consistent – in TXP CMS logic – than a ‘wild’ HREF construction.
Design: If you wrap the txp:category
tag(s) in <ul>...</ul>
and use wraptag="li"
you can create a beautiful and readable/manageable navigation box inside a TXP form.
The example from the documentation:
Example 3: Display a specific category’s title, hyperlinked
<txp:category name="articles" title="1" link="1" wraptag="p" />
Last edited by merz1 (2010-03-18 19:57:29)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#9 2010-03-19 07:30:08
- dandul
- Member
- From: Brisbane, Australia
- Registered: 2010-01-31
- Posts: 33
Re: Go straight to category articles in another section
Thanks Merz1, that construction is much cleaner and it has the same effect as the ‘wild’ reconstruction. I’ve used it and it’s working well. Thanks for the tip. :)
Stop wishing things were different to the way they are. Accept it, deal with it, move on.
Offline
Re: Go straight to category articles in another section
You might not see the effect immediately but it is always good to avoid hard coded HTML if an appropriate TXT tag is available. TXP will automagically update your site eg if you change the category or section title.
The bigger & more complex your site logic gets, the more important it is to use a clean syntax. Well, as I said, you started wrong but I hope you are now aware of possible consequences if you run into trouble in the ‘far far away’ future :)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: Go straight to category articles in another section
Hi. I’m trying to have my categorized articles land not on my home page, but on my articles page. Here’s the trail…
On my home page I have a few articles. When one clicks an article, they’re taken to my Articles page. Once on the Articles page, at the bottom of the Article they were reading, there is a link to other Articles within that Category (e.g.: Advocacy). When they click the “advocacy” link, the reader is then returned to the Home page where other Advocacy articles appear.
My question is, How can I make these category links (e.g.: Advocacy) land back on the Articles page and not the Home page? I’ve poked around in the article forms (looking for category clues, but don’t see anything.)
Thanks much.
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: Go straight to category articles in another section
If your “articles” page is a section, then Merz’s solution with the additional section="articles"
attribute in the post above should work for you:
<txp:category section="articles" name="advocacy" link="1" title="1" />
which should produce a link to an address as follows:
http://www.mydomain.com/articles/?c=advocacy
TXP Builders – finely-crafted code, design and txp
Offline