Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 Yesterday 05:45:56
- code365
- Member
- From: California
- Registered: 2009-08-16
- Posts: 115
Match article with categories
Hi TXP Community,
Hopefully, this makes sense. I have a section called coaching. I have a coaching dropdown menu (URL link) which pulls several article titles from the categories name coach.
I am trying to have it when someone clicking on anyone article title, it brings up the main article along with the additional articles associated to the article. I can get a single article to display on the page, but not the associate articles to show on the page.
Would it be possible to do this with TXP? And if so, can you please help?
Thank you,
Offline
Re: Match article with categories
related_articles returns articles from the same section and category. You can achieve similar results with article_custom.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#3 Yesterday 07:11:48
- code365
- Member
- From: California
- Registered: 2009-08-16
- Posts: 115
Re: Match article with categories
Colak,
I am able to return the articles from the category, but the added article is not attached to the article. It displays the same article for the main article. Should I create a sub category folder under the main category with the article?
Last edited by code365 (Yesterday 07:19:48)
Offline
Re: Match article with categories
Hi
How you decide wich article is related to another ? same category ? same section ? or what ?
Cheers.
Offline
Re: Match article with categories
Colak’s tip is good. Check the related_articles examples for how to use the tag.
You’d use this on the individual_article view, either in your page template by adding your related_articles tag to the <txp:if_individual_article>…</txp:if_individual_article>
section of the page template, or alternatively – depending on your page layout – in the form you use to display a main article.
When you click on your article title, it should then show a page with the main article (displayed using the regular txp:article
tag) and then related articles in the same category or categories using the txp:related_articles
tag.
TXP Builders – finely-crafted code, design and txp
Offline
#6 Yesterday 13:53:10
- code365
- Member
- From: California
- Registered: 2009-08-16
- Posts: 115
Re: Match article with categories
@Dragondz, that is what I am trying to understand. The example TXP provides is only a brief description.
@jakob is it possible to point me or give example better example than TXP short example. I am still trying to get my head wrapped around on how to use TXP tags injunction with other TXP tags in complex projects, like this one.
This is one of the reasons I love using TXP because of it community support.
Thank you, TXP community
Last edited by code365 (Yesterday 18:28:18)
Offline
Re: Match article with categories
code365 wrote #338147:
@jakob is it possible to point me or give example better example than TXP short example. I am still trying to get my head wrapped around on how to use TXP tags injunction with other TXP tags in complex projects, like this one.
The examples in the docs are already informative. It probably becomes clearer if you try it out. Here’s a very simple setup with the related_articles tag in the context of a setup similar to what you described above:
<!-- navigation / select menu -->
<nav>
<select name="select_menu" onchange="document.location.href=this.value">
<option selected value="">Select an article</option>
<txp:article_custom section="coaching" break="" wraptag="">
<option value="<txp:permlink />"<txp:if_article_id> selected</txp:if_article_id>><txp:title /></option>
</txp:article_custom>
</select>
</nav>
<!-- main content -->
<main>
<!-- article list on section landing page / individual article on article url -->
<txp:article />
</main>
<!-- sidebar -->
<aside>
<!-- if showing an individual article ... -->
<txp:if_individual_article>
<!-- ... show related articles by category, excluding the current article -->
<txp:related_articles wraptag="ul" break="li" class="related-article-list" label="Related articles" labeltag="h3" />
</txp:if_individual_article>
</aside>
This gives you:
- a select menu at the top built with article_custom. txp:article_custom ignores the current context, so you need to specify the section for the articles to show. This is just an example and might be part of your main nav.
- on your coaching landing page: an article list in the main content area
on an individual coaching article: the article content
This is context-sensitive: it will use whatever form you specify in thelistform
attribute for thedomain.com/section/
url (by default thearticle_listing
form) and whatever form you specify in theform
attribute for displaying an individual article (by default thedefault
form). Create your own forms and specify the attributes to customise your output. - on an individual article, a list of other articles with a matching category. This is context-sensitive in that it looks at the categories assigned for the current article and lists other articles that are assigned to the same categories, excluding the current article that is showing. Here too, you can provide a
form
attribute to customise the output. The standard output is<txp:permlink><txp:title /></txp:permlink />
.
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1