Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2015-05-21 00:05:15

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

Re: output all articles from sections to homepage

jacob – thanks for your comments and suggestions. I do wish to make this a open-source template for Textpattern users. It’s in fact based on a open source bootstrap theme.

I am not happy about the use of IDs for the very reason you mention. But i was not able to figure out how to do it differently. In EE one can restrict all output to a channel. Declare a channel and then output what ever you want. I have never been able to figure how to that with TxP

I do have Sections. And each Section use a particular output form. Are you saying i can get away from using sections all-together?

The Overide Form function is not clear to me: The info says:

Articles: Override form
If you wish for an article to use a form different from that assigned by default – for example if you want to show only an article excerpt with <txp:excerpt /> where you normally show the entire article with <txp:body /> – this can be set here.</em>

This sounds like you override one form for another. Don’t I still need to have the forms created?

jakob wrote #290954:

Instead of txp:permlink, you could use txp:article_url_title to create the anchor links and corresponding ids, and use txp:title for the comments in your code ;-) The only tricky bit is the portfolio page with the sub-pages. I’m thinking you could probably do that with a section to hold your portfolio items and an extra txp:article_custom tag, or perhaps using categories.

I’ll have to explore those options.

People could then create their own articles, choose a corresponding “override form” to match a particular layout and then adjust the order, either via the date or stm_article_order.

That would be my goal, but not sure how if i can accomplish it all.


…. texted postive

Offline

#17 2015-05-22 14:43:09

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

Re: output all articles from sections to homepage

etc wrote #290847:

or equivalently id="2,4,3,1" sort="".

Wow! That’s undocumented, I suppose. Is it valid for any TXP tag with sort option?


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

Offline

#18 2015-05-22 14:55:55

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

Re: output all articles from sections to homepage

uli wrote #291008:

Is it valid for any TXP tag with sort option?

Not sure for <txp:linklist /> and <txp:file_dowload_list /> (rather not). For <txp:images /> it must work, but only with id attribute.

Offline

#19 2015-05-30 18:24:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,205
Website GitHub

Re: output all articles from sections to homepage

Sorry, I realise I totally forgot to reply to you.

Well, if you have your articles already in different sections you could use a combination of sections, sticky + live articles, and forms named after your sections.

For your main menu you could do this:

<txp:section_list include_default="1" default_title="Home" sections="about,services,portfolio,contact" wraptag="ul" break="li" class="site-nav">
  <a href="#<txp:section />"><txp:section title="1" /></a>
</txp:section_list>

Then make a form for each of your layout “bands” on the page and name them consistently with the name of the section, for example layout_about, layout_services, layout_portfolio, layout_contact.

For the sections that have sub-items such as the service spectrum and the portfolio items, create additional forms with a similar pattern, e.g. layout_services_sub and layout_portfolio_sub for just the display of the sub-item plus its containing tags (see below for an example).

Then set the status of all the main articles for each “band” to “sticky”, and the leave the status of all the articles with sub-items (the service types and portfolio items) as live articles.

To output the rest of the site, you can then do something like this in your page template:

<txp:section_list sections="about,services,portfolio,contact" break="">

  <!-- <txp:section /> section -->
  <section id="<txp:section />">
    <h2><txp:section title="1" /></h2>

    <!-- general layout = sticky article -->
    <txp:article_custom section='<txp:section />' status="sticky" form='layout_<txp:section />' break="" />

    <!-- layout of sub-items = live articles -->
    <txp:article_custom section='<txp:section />' status="live" form='layout_<txp:section />_sub' break="" />

  </section>

</txp:section_list>

(Note the use of single quotes for the tag-in-tags). That should loop through each of the sections in order, creating a section with heading and anchor, and outputting the sticky article (if there is one) followed by the live articles (if there are any).

Here’s an example of a sub-item form, e.g. layout_portfolio_sub. If you need to wrap the sub-items in a container, you can make use of if_first_article and if_last_article, for example:

<txp:if_first_article>
  <div class="container">
    <div class="row">
</txp:if_first_article>

      <article class="col  portfolio-box">
        <txp:article_image />
        <div class="caption-container">
          <h3><txp:title /></h3>
          <txp:category1 wraptag="h4" />
        </div>
      </article>

<txp:if_last_article>
    </div>
  </div>
</txp:if_last_article>

In cases where you might want to have user-editable sections in each band not just above but also below the sub-items, you could either:

  • Use two sticky articles, one for the top and another for the bottom and do this in your page template: article_custom status="sticky" limit="1" … then article_custom status="live" … and then article_custom status="sticky" offset="1".
  • Or perhaps more simply: take the article_custom status="live" line out of the page template and put it into the body of your sticky article at the place where you want to have it. That’s probably easier for an own site, but potentially breakable by the user for a public theme.

The one limitation with this approach is that you can only have one of each “band”, as they are tied to sections and you can’t have more than one with the same name. If you’d like to define repeating sections that can come up again at different stages down the page, you need to use the other method with the “override form”.

The other thing you need to catch with whatever variant you use is what happens when someone enters www.yourdomain.com/about instead of …#about. Either:

  • you assign all the sections the same page template so that they always show the same content. You could perhaps use javascript to grab the current section and make it jump to the respective section as it would do normally if you clicked the menu button.
  • you use one of the redirect plugins to redirect your sections to #section. If it’s a public theme, other users would need to add their section redirects. Maybe the unofficial smd_redirect would help here as it allows regex rules (not sure if other redirect plugins like arc_redirect etc. support regex patterns, though)
  • you use an htaccess rule to redirect /section to #section. That’s not so user-friendly for a theme but works most invisibly.

TXP Builders – finely-crafted code, design and txp

Offline

#20 2015-05-31 23:30:08

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

Re: output all articles from sections to homepage

Jakob – many thanks for your solutions!! I hopefully will be able to work on this issue soon …


…. texted postive

Offline

Board footer

Powered by FluxBB