Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-05-17 09:56:23

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

Re: output all articles from sections to homepage

uli wrote #290844:

you can manually sort for IDs : id="1,2,3,4" sort="field(id,2,4,3,1)"

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

Edit: since v.4.5, sort="" is default and hence unnecessary here.

Last edited by etc (2015-05-31 13:45:26)

Offline

#14 2015-05-20 20:02:44

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

Re: output all articles from sections to homepage

Thanks to all of you who offered suggestions ! have used the code suggested in this thread to produce this one page site based on a bootstrap theme.

I ended up using the custom form tag.

<txp:article_custom form="one_page" id="2" /><!--   Home  -->        
<txp:article_custom form="about_page"  id="3" />   <!-- About  -->             
<txp:article_custom form="yourservice_page"  id="17" /> <!-- Your Services  -->              
<txp:article_custom form="services_page" id="4" /> <!-- Sturdy "-->
<txp:article_custom form="services_page" id="5" /> <!-- Responsive -->
<txp:article_custom form="services_page"  id="6" /> 
<txp:article_custom form="services_page"  id="7" /> <!-- Made with Love -->
 <!-- portfolio output -->              
<txp:article_custom form="portfolio_page" id="12,10,15,9,13,14" sort="" /> 
<txp:article_custom form="conversation_page" id="16" />
<txp:article_custom form="contact_page"  id="8" />

and i have used 7 Forms as each section had a unique css design that was not in common with all sections.

I also had no need for the <txp:permlink> tag as i wanted the sections to be accessed as this example:

<a href="#services" class="btn btn-default btn-xl"><txp:excerpt /></a>
<a href="#about" class="btn btn-default btn-xl"><txp:excerpt /></a>

etc

All the text on the page can be changed/edited by an Editor via the control panel as are the images in the portfolio.

I hand coded the navigation for now, will look to to see if that can be automated, although there will never be any additional sections to be added .

<li> <a class="page-scroll" href="#about">About</a>
       </li>
       <li> <a class="page-scroll" href="#services">Services</a>
        </li>

Again many thanks to all for your suggestions and submissions!


…. texted postive

Offline

#15 2015-05-20 20:58:24

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

Re: output all articles from sections to homepage

Bici, your site’s looking good – and it looks like you found a way to manage it how you want it.

If you are planning on publishing it as an open-source template, you might want to go the extra mile to optimise it a bit and make it more flexible – it will reduce the questions you get about how to adapt it. At present, it’s very tied to your precise article structure. That’s perfectly okay, of course, for your own purposes, but if someone else uses the template, and their article id numbers are just one-off, it stops working as intended. Same too, if they decide, they don’t need a particular type of layout. Also, as you have it now, each article_custom tag is a fresh database query.

I can see now that you’re not using sections at all to create the structure, just articles, so my suggestion earlier in this thread doesn’t really help, but you could use the „Override form“ as Uli suggested and use just one txp:article or txp:article_custom tag. That would be perfect for this kind of page setup, where there are layout bands that can be used in different orders and combinations (there are lots of templates out there that are built that way – see the stuff from UI8, Designmodo and Visualhierarchy). It would also release you from having to use exact ID numbers, and would make it possible to auto-build a corresponding menu.

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.

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. The menu would adapt with it. If you want to avoid using txp:article_custom twice for the menu, you could either try a trick with a cumulative txp:variable and place your menu at the bottom of the page, or use etc_query to construct the menu from the txp:article output…


TXP Builders – finely-crafted code, design and txp

Offline

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

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
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,304

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,053
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: 4,596
Website

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,075
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