Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-05-16 00:05:54

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

output all articles from sections to homepage

I have 5 sections : Home About Services Portfolio Contact and i want to output all the articles from the sections to the home page and use #anchor urls. So far i hacked this to work up to the Services section using custom_form and custom field keywords. But i have run out of custom fields to now handle the Portfolio section which will have 6 articles.

 <txp:article_custom form="one_page" Home="Home" /

and for the services i used

<txp:article_custom form="services_page" Sturdy="Sturdy" />
But i have used up 9 of the custom_fields so now i am stuck on how to output the Portfolio section.

I may have not setup the output of EACH section to the home page correctly. When i did not use the Custom Field keyword option the articles from the sections were being outputted out of order. I think i may have to have an individual Article Form for each Section??

Last edited by bici (2015-05-16 00:07:48)


…. texted postive

Offline

#2 2015-05-16 01:33:32

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: output all articles from sections to homepage

You have to select in the section panel for each section “yes” for “on front page”. It’s a little bit old but maybe this helps, point “f”. You don’t need the help of custom fields to do this. Only the article tag and the desired sorting criteria. For a manual order the stm_article_order plug-in is a great help.

Last edited by GugUser (2015-05-16 01:44:35)

Offline

#3 2015-05-16 03:11:16

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: output all articles from sections to homepage

GugUser wrote #290808:

You have to select in the section panel for each section “yes” for “on front page”. It’s a little bit old but maybe this helps, point “f”. You don’t need the help of custom fields to do this. Only the article tag and the desired sorting criteria. For a manual order the stm_article_order plug-in is a great help.

I had that option selected to YES appear on Front page. But articles from one section were overwriting other articles from other sections. I’l look to trying it again , without use of custom fields.


…. texted postive

Offline

#4 2015-05-16 05:04:10

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: output all articles from sections to homepage

HI bici, please correct me if I understood it wrongly. I understand that you need articles from all sections to appear on the front page and link those articles to their individual pages. Furthermore you need the articles on the front page to be divided under their sections.

If it actually is the case, would the code below do?

<txp:if_section name="">
<section>
<h1><a rel="section" href="/about/">About</a></h1>
<txp:article_custom section="about"><h2><txp:permlink><txp:title /></txp:permlink></h2></txp:article_custom>
</section>
<section>
<h1><a rel="section" href="/services/">Services</a></h1>
<txp:article_custom section="services"><h2><txp:permlink><txp:title /></txp:permlink></h2></txp:article_custom>
</section>
<section>
<h1><a rel="section" href="/portfolio/">Portfolio</a></h1>
<txp:article_custom section="portfolio"><h2><txp:permlink><txp:title /></txp:permlink></h2></txp:article_custom>
</section>
<section>
<h1><a rel="section" href="/contact/">Contact</a></h1>
<txp:article_custom section="contact"><h2><txp:permlink><txp:title /></txp:permlink></h2></txp:article_custom>
</section>
</txp:if_section>

You can of course change the code to suit your needs or let us know and we’ll help.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2015-05-16 08:58:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: output all articles from sections to homepage

Also not sure if I misunderstood you, but could you not use either of these two methods:

1. txp:section_list with a nested txp:article_custom:

<txp:section_list sections="home,about,services,portfolio,contact">
  <section id="<txp:section />">
    <h2><txp:section title="1" /></h2>
    <txp:article_custom section='<txp:section />' limit="99" break="article" wraptag="">
      <h3><txp:permlink><txp:title /></txp:permlink></h3>
    </txp:article_custom>
  </section>
</txp:section_list>

(Note: single quotes for tag in tag for the section attribute of txp:article_custom).

2. txp:article_custom and txp:if_different sorting by section and then posted date. This has fewer database queries, but making section / div containers as in the example above is more difficult. You need esq_sectionsort for this to define the order of your sections (needed for the sectionsort sort criteria):

<txp:article_custom section="home,about,services,portfolio,contact" limit="999" break="" sort="sectionsort desc, posted desc">
  <txp:if_different>
    <h2 id="<txp:section>"><txp:section title="1" /></h2>
  </txp:if_different>
  <article>
    <h3><txp:permlink><txp:title /></txp:permlink></h3>
  </article>
</txp:article_custom>

(I vaguely remember there was a sort order trick for maintaining the order of the sections as entered in the sections attribute without needing esq_sectionsort, but I couldn’t recall/ find it. Can anyone else help there?)

You could also use stm_article_order as Guguser mentioned to additionally sort the articles. And if you want the articles output in different ways for different sections, you can use Yiannis’ txp:if_section blocks. You shouldn’t need custom fields for either of these options.

Note: If I recall correctly, the “show on homepage” button only applies if you use txp:article (i.e. the context-sensitive tag). txp:article_custom always ignores context.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2015-05-16 09:38:21

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: output all articles from sections to homepage

jakob wrote #290818:

<txp:article_custom section="home,about,services,portfolio,contact" limit="999" break="" sort="sectionsort desc, posted desc">...

(I vaguely remember there was a sort order trick for maintaining the order of the sections as entered in the sections attribute without needing esq_sectionsort, but I couldn’t recall/ find it. Can anyone else help there?)

I would be curious to see it. There is also etc_sort.

Note: If I recall correctly, the “show on homepage” button only applies if you use txp:article (i.e. the context-sensitive tag). txp:article_custom always ignores context.

Yes, unless you pass <txp:article_custom /> the undocumented frontpage="1" attribute (at least it looks like this in the code).

Offline

#7 2015-05-16 09:50:44

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: output all articles from sections to homepage

I would be curious to see it.

I think I confused this up with the FIELD trick for keeping image id# in order, which won’t work here.

There is also etc_sort.

Cool. If you don’t need to make things user-sortable on the admin end, then etc_sort looks much better.

the undocumented frontpage="1" attribute

That’s something else I didn’t know. Thanks!


TXP Builders – finely-crafted code, design and txp

Offline

#8 2015-05-16 17:03:27

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: output all articles from sections to homepage

Thanks all! I am going to try the suggestions next week.( long weekend off) I will try to get it working,
I am attempting at duplicating a bootstrap theme, and have all the text entries handled by TxP so that a user can update the text and (images in portfolio sections). see this example

(Once it’‘s all working I’ll put it up on Git for others to use as there are no licensing restrictions)


…. texted postive

Offline

#9 2015-05-16 17:25:59

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: output all articles from sections to homepage

ps this code is working fine BUT I have not done the portfolio section …. which would drive me crazy if i tried my current code to try and handle the six portfolios articles with the image and text.

<txp:output_form form="meta_head" />
<body id="page-top">
<txp:output_form form="nava" />
<txp:article_custom form="one_page" limit="1"  offset="6" /><!-- Home  -->
<txp:article_custom form="about_page"  limit="1"  offset="5" />   <!-- About -->
<txp:article_custom form="services_page" limit="1" offset="4" /> <!-- Sturdy"-->
<txp:article_custom form="services_page" limit="1" offset="3" />  <!-- Responsive-->
<txp:article_custom form="services_page"  limit="1" offset="2" /> <!-- Up2date-->
<txp:article_custom form="services_page"  limit="1" offset="1" /> <!-- Made-->
<txp:article_custom form="contact_page"  limit="1" offset="0" /><!-- CONTACT -->
<txp:output_form form="footer" />
<!-- DONE -->

pps i am sure some will giggle at my attempts ;-)


…. texted postive

Offline

#10 2015-05-16 19:08:46

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: output all articles from sections to homepage

Would this meet your needs?

<txp:article_custom section="portfolio">
<figure>
<txp:permlink><txp:article_image thumbnail="1" /></txp:permlink>
<figcaption>
<h2><txp:permlink><txp:title /></txp:permlink><h2>
<txp:excerpt />
</figcaption>
</figure>
</txp: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

#11 2015-05-16 22:14:47

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: output all articles from sections to homepage

bici wrote #290838:

form="one_page"
form="about_page"
form="services_page"
form="services_page"
form="services_page"
form="services_page"
form="contact_page"

Remember there’s “Override form” in the Write panel, individually for each article. And you can manually sort for IDs : id="1,2,3,4" sort="field(id,2,4,3,1)"
id="2,4,3,1"

Edited my proposal following a discussion that came to this result .

Last edited by uli (2015-05-31 14:13:34)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#12 2015-05-17 03:06:57

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: output all articles from sections to homepage

bici wrote #290837:

See this example

Thanks to your example I begin to understand what you want to do. This is very easy, don’t difficult your life with complicated constructions. jakob gave you a general solution in his first example.

You don’t need all this custom fields. For sorting the article order, and because you have a limited number of articles, you can use for each section the mentioned stm_article_order plugin or just accommodate the publish date. That’s no so much effort for only six articles.

Offline

Board footer

Powered by FluxBB