Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Outputing a list of articles for specific category on landing page
I don’t consider myself a noob anymore but i am really struggling with the logic of what seems to me a very simple request.
How to produce a list of articles (not an article list): for specific category on landing page. These articles all need to link to their respective children categories, which in turn produce their list of articles
–main-category
––sub-category
–––sub-sub-category
––––sub-sub-sub-category
––––sub-sub-sub-category
––––sub-sub-sub-category
––––sub-sub-sub-category
<h1>main-category title <txp:category title="1" /></h1>
<ul class="main-category">
<txp:article_custom category="main-category">
<li>
<a href="<txp:permlink"> title="link to sub-category">
<span class="entry-title"><txp:custom_field name="sub-category" /></span>
<txp:article_image />
</a>
</li>
</txp:article>
</ul>
The article_custom tag outputs nothing?? which seems illogical to me. Why is this?
Last edited by Timid&friendly (2010-05-30 08:50:14)
I think, therefore I AM, … … er … I think :-?
Offline
Re: Outputing a list of articles for specific category on landing page
Hi
I think there is an error on your code, because you end it wit txp:article instead of article_custom
but your code will only output articles in main_category and not in subcat!
to do what you want you must use txp:category_list above txp:artcile_custom
Cheers
Last edited by Dragondz (2010-05-30 09:09:01)
Offline
Re: Outputing a list of articles for specific category on landing page
Thx well spotted, that was just a typo in forum (i have had to simply code so that my question is clearer). Although my question seems to still be unclear. Perhaps this makes it clearer?
You can see these pages as landing-pages or portal-pages which with every click deeper show more specific pages ( as in Main-cat=“Car” > Sub-cat=“ford” > Sub-sub-cat=“fiesta” > Sub-sub-sub-cat=fiesta2010 model” )
1. I dont want a list of cat titles. I want a list of main-cat articles.
2. When an main-category article link is clicked this needs to link to sub-category landingpage and output a list of articles belonging to sub-category
3. When one of the sub-category links is clicked this in needs to link to sub-category landingpage and output a list of sub-sub-category articles… and so on and so on deeper and deeper
An hierarchical stepup each time going a layer deeper and showing all relevant articles belong to the specific child category
Last edited by Timid&friendly (2010-05-30 12:50:42)
I think, therefore I AM, … … er … I think :-?
Offline
#4 2010-05-30 13:33:26
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Outputing a list of articles for specific category on landing page
I don’t quite understand how you are using the custom field. Didn’t you create the parent-children structure in your categories?
Offline
Re: Outputing a list of articles for specific category on landing page
Yes i did create parent>child>subchild etc structure.
You can probably ignore that aspect. That’s an extra option i am playing with in this development stage. To clarify you could of course use a catergory name if it’s technically feasible. Lower down the chain i need get article(product)specifics from custom fields that can’t be covered with category names.
I guess my first question is:-
1. can you output a list of articles of a specific category on the section landingpage?
2. can you use each of these articles(with this parent category) to link to a specfic sub(child)-category and output all articles belonging to that sub(child)-category? (but excluding the (main/parent category and all nested children categories).
3. can this structure be reiterated to allow one to go deeper and deeper into the site?

Last edited by Timid&friendly (2010-05-30 16:56:07)
I think, therefore I AM, … … er … I think :-?
Offline
Re: Outputing a list of articles for specific category on landing page
I guess i’m a bigger txpnood than i thought, though i have managed to figure out how to output a list of Catergory articles on landing page. For those who also struggle with this:-
For most of my section (main-nav) i used the txp:section_list active_class="current" sections="my-section" />. But for the Section that holds all the categories, i had to make up a category with the same name as the section and replaced the section txp tag with <txp:category_list active_class="current" section="assortiment" categories="assortiment" break="" />
This starts the chain i needed to output category article lists.
There may be a better way but this works.
I think, therefore I AM, … … er … I think :-?
Offline
#7 2010-06-01 18:44:53
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Outputing a list of articles for specific category on landing page
Sorry, I hadn’t noticed you updated your previous post. Does this mean all three of your questions are answered now?
Offline
Re: Outputing a list of articles for specific category on landing page
I haven’t solved point 2 and 3. But had no time as yet.
I think, therefore I AM, … … er … I think :-?
Offline
#9 2010-06-01 20:21:44
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Outputing a list of articles for specific category on landing page
Still not quite sure what you want. Something like this?
- (Section) page /assortiment/:
- article 1 in category Assortiment, linking to child category Export
- article 2 in category Assortiment, linking to child category Partner
- article 3 in category Assortiment, linking to child category Unique
- etcetera
- Page /assortiment/?c=export:
- article 1 in category Export, linking to child category Full-color
- article 2 in category Export, linking to child category Multi-color
- etcetera
- Page /assortiment/?c=full-color:
- article 1 in category Full-color, linking to one of its child categories (if any)
- etcetera
Offline
Re: Outputing a list of articles for specific category on landing page
Yeah that’s exactly what i am trying to do!
I think, therefore I AM, … … er … I think :-?
Offline
#11 2010-06-02 07:01:30
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Outputing a list of articles for specific category on landing page
In that case you could store the child category that an article should link to in a custom field (I think you mentioned that before).
You don’t need to change your section_list tag, if you set it up so that your ‘Assortiment’ section’s landing page only has articles in category ‘Assortiment’:
<txp:if_section name="assortiment">
<txp:if_individual_article>
<txp:article form="yoursinglearticleform" />
<txp:else />
<txp:if_category>
<!-- this is a child category page -->
<txp:article form="yourlistform" />
<txp:else />
<!-- this is the section landing page -->
<txp:article_custom section="assortiment" category="assortiment" form="yourlistform" />
</txp:if_category>
</txp:if_individual_article>
</txp:if_section>
(If section Assortiment has its own page template you can of course leave out the if_section tags.)
In form ‘yourlistform’ use something like this to link to the child category:
<txp:if_custom_field name="linktochildcat">
<txp:category name='<txp:custom_field name="linktochildcat" />' title="1" link="1" />
</txp:if_custom_field>
Offline
Re: Outputing a list of articles for specific category on landing page
Looks Great Els! THX! I will try this out a.s.a.p.
I think, therefore I AM, … … er … I think :-?
Offline
Re: Outputing a list of articles for specific category on landing page
The form beneath is called with this <txp:article_custom section="assortiment" category="assortiment" form="-landing-subcat" />
And outputs this:-
<txp:if_custom_field name="Subcategorie">
<txp:category name='<txp:custom_field name="Subcategorie" />' title="1" link="1" />
</txp:if_custom_field>
Unfortunately There are two problems:
1. The form outputs nothing on landing page. (when i use another form with the content underneath it works, but of course wrong uri destination).
2. Secondly <txp:category ... link="1" /> outputs only a link and doesn’t allow me to dictate what aspects of the article are rendered i.e. <txp:image /> etc. etc. I don’t want just the title or a custom_field I need access to everything the article contains.
This is an example of the type of article output i require:
<li class="sub-category <txp:custom_field name='Subcategorie' />" id="<txp:article_id />">
<h2>
<a href="<txp:permlink />"> <!-- Should actually be a linktochildcat and not to individual article -->
<span class="entry-title">
<span class="type"><txp:custom_field name="Hoofdcategorie" /> 
<if_txp:custom_field name="Subcategorie">
<txp:custom_field name="Subcategorie" />
</if_txp:custom_field>
</span>
</span>
<span class="entry-image">
<txp:article_image />
</span>
</a>
</h2>
</li>
Last edited by Timid&friendly (2010-06-02 18:04:52)
I think, therefore I AM, … … er … I think :-?
Offline
#14 2010-06-02 18:16:22
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Outputing a list of articles for specific category on landing page
Re #2: replace <a href="<txp:permlink />"> with this:
<a href="<txp:site_url /><txp:section />/?c=<txp:custom_field name="Subcategorie" />">
Re #1: It outputs nothing on the landing page, but it does on the category pages? Can you post a tag trace of the landing page?
BTW, if_txp:custom_field should be txp:if_custom_field, but I guess you know that ;)
Offline
Re: Outputing a list of articles for specific category on landing page
Thx Els
<!-- txp tag trace:
[SQL (0.00417184829712): select name, data from txp_lang where lang='en-gb' AND ( event='public' OR event='common')]
[SQL (0.00145792961121): select name, code, version from txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (0.000200986862183): select name,code,version from txp_plugin where status = 1 AND name='soo_txp_obj']
[SQL (9.67979431152E-5): select name,code,version from txp_plugin where status = 1 AND name='soo_plugin_pref']
[SQL (0.000329971313477): select name, val, html, position from txp_prefs where name like 'soo_multidoc.%' order by position asc]
[SQL (0.000265836715698):
SELECT
`name` AS custom_set,
`val` AS name,
`position`,
`html` AS type
FROM
`txp_prefs`
WHERE
`event`='custom'
ORDER BY
`position`
]
[SQL (0.000248908996582):
SELECT
`name`, `val`
FROM
`txp_prefs`
WHERE
`html` = 'date-picker'
AND
`name` LIKE 'custom_%'
ORDER BY
`name`
]
[SQL (0.000255823135376):
SELECT
`name`, `val`
FROM
`txp_prefs`
WHERE
`html` = 'time-picker'
AND
`name` LIKE 'custom_%'
ORDER BY
`name`
]
[SQL (0.00023889541626): select name from txp_section where `name` like 'assortiment' limit 1]
[SQL (0.000146150588989): select page, css from txp_section where name = 'assortiment' limit 1]
[SQL (0.000386953353882): select `ID` from textpattern where `Status` > '3' and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Posted <= now()]
[SQL (0.000240087509155): select `ID`,`custom_5` from textpattern where `custom_5` regexp '[[:digit:]]']
[SQL (0.000310182571411): select host from txp_log where ip='234.678.123.345' limit 1]
[SQL (0.000228881835938): insert into txp_log set `time`=now(),page='/site/txp/assortiment/',ip='234.678.123.345',host='234.678.123.345.ip.telfort.nl',refer='',status='200',method='GET']
[SQL (0.000208854675293): select user_html from txp_page where name='landingpage new backup']
[Page: landingpage new backup]
<txp:output_form form="-head" />
[SQL (0.000211954116821): select Form from txp_form where name='-head']
[Form: -head]
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:if_section name="">
[<txp:if_section name="">: false]
<txp:section />
</txp:if_section>
<txp:if_individual_article>
[<txp:if_individual_article>: false]
</txp:if_individual_article>
<txp:output_form form="-accessibility" />
[SQL (0.000119209289551): select Form from txp_form where name='-accessibility']
[Form: -accessibility]
<txp:output_form form="-branding-nav" />
[SQL (0.000125169754028): select Form from txp_form where name='-branding-nav']
[Form: -branding-nav]
<txp:link_to_home>
<txp:site_url />
</txp:link_to_home>
<txp:site_slogan />
<txp:section_list active_class="current" sections="default" default_title="Voorpagina" sections="default" />
[SQL (0.00012993812561): select name, title from txp_section where name in ('default') order by field(name, 'default')]
<txp:section_list active_class="current" sections="over-penpoint" />
[SQL (0.000125885009766): select name, title from txp_section where name in ('over-penpoint') order by field(name, 'over-penpoint')]
<txp:if_section name="over-penpoint">
[<txp:if_section name="over-penpoint">: false]
</txp:if_section>
<txp:if_section name="assortiment">
[<txp:if_section name="assortiment">: true]
</txp:if_section>
<txp:section_list active_class="current" sections="assortiment" />
[SQL (0.000126838684082): select name, title from txp_section where name in ('assortiment') order by field(name, 'assortiment')]
<txp:if_section name="assortiment">
[<txp:if_section name="assortiment">: true]
<txp:category_list active_class="current" section="assortiment" categories="export-landingpage" break="li" />
[SQL (0.000241994857788): select name, title from txp_category where type = 'article' and name in ('export-landingpage') order by field(name, 'export-landingpage')]
<txp:category_list active_class="current" section="assortiment" categories="penpoint-partner,unique" break="li" />
[SQL (0.000165939331055): select name, title from txp_category where type = 'article' and name in ('penpoint-partner','unique') order by field(name, 'penpoint-partner','unique')]
</txp:if_section>
<txp:section_list active_class="current" sections="aanbiedingen" />
[SQL (0.000136137008667): select name, title from txp_section where name in ('aanbiedingen') order by field(name, 'aanbiedingen')]
<txp:if_section name="aanbiedingen">
[<txp:if_section name="aanbiedingen">: false]
</txp:if_section>
<txp:section_list active_class="current" sections="contact" />
[SQL (0.000128984451294): select name, title from txp_section where name in ('contact') order by field(name, 'contact')]
<txp:if_section name="contact">
[<txp:if_section name="contact">: false]
</txp:if_section>
<txp:if_individual_article>
[<txp:if_individual_article>: false]
<txp:if_category>
[<txp:if_category>: false]
<txp:article_custom section="assortiment" category="assortiment" form="-landing-subcat" />
[SQL (0.000577211380005): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('assortiment') or Category2 IN ('assortiment')) and Section IN ('assortiment') order by Posted desc limit 0, 10]
[article 58]
[SQL (0.000120878219604): select Form from txp_form where name='-landing-subcat']
[Form: -landing-subcat]
<txp:if_custom_field name="Subcategorie">
[<txp:if_custom_field name="Subcategorie">: false]
</txp:if_custom_field>
[article 57]
[Form: -landing-subcat]
<txp:if_custom_field name="Subcategorie">
[<txp:if_custom_field name="Subcategorie">: false]
</txp:if_custom_field>
[article 56]
[Form: -landing-subcat]
<txp:if_custom_field name="Subcategorie">
[<txp:if_custom_field name="Subcategorie">: false]
</txp:if_custom_field>
</txp:if_category>
</txp:if_individual_article>
<txp:output_form form="-footer" />
[SQL (0.000119209289551): select Form from txp_form where name='-footer']
[Form: -footer]
[ ~~~ secondpass ~~~ ]
-->
Last edited by Timid&friendly (2010-06-03 04:52:46)
I think, therefore I AM, … … er … I think :-?
Offline