Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-10-04 02:25:51

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

How do I make the Home page a Main Section Overview

I feel I should know the answer to this backwards but I am struggling to work out how to get a section landing page as well as article lists from a TXP article form. On a long established site, essentially, my default article form is like this:

<txp:if_individual_article>
	<txp:output_form form = "an_article"/>
	<txp:else />
	<txp:output_form form="list_of_articles" />
</txp:if_individual_article> 

and is called from a section page with simply:

<txp:article limit="999" sort="posted"/>

It’s not used for Home/Default but for the main Section of the site, let’s call it ‘Cars’.

Currently, the url mysite.com/cars produces a list of all the car articles but we don’t ever call that url from the Nav. We only use mysite.com/cars/?c=marque to produce a list of cars in a particular marque as defined by a TXP category.

We now need to add password protection to the Cars section content and to move the current Home/Default article in there, same content but now called “Overview” and status ‘Sticky’. Those who log in successfully needs someplace to land, for instance, and my site.com/cars with Overview landing page will do that nicely. The new home page will carry a much briefer overview, no navigation to keep the list of marques discreet, and just a button/link to mysite.com/cars which will invoke the htaccess password protection browser login dropdown etc.

Except, I can’t remember how to achieve it with an article form.

Last edited by joebaich (2016-10-04 02:51:48)

Offline

#2 2016-10-04 09:11:41

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

Re: How do I make the Home page a Main Section Overview

To show a specific section landing article in addition to the respective context, you can simply do:

<txp:article_custom id="123" form="intro_article" />

where 123 is the article number. Place that within your if_logged_in / else (however you are doing that) and if_individual_article / if_article_list conditionals if you need it display when logged in to make it display as needed.

The other way is to use a sticky article and use the article tag twice:

<txp:article status="sticky" limit="1" form="intro_article" />
<txp:article form="an_article" listform="list_of_articles" limit="999" />

or using your if_individual_article / if_article_list conditionals if your prefer. With this last arrangement the sticky will only show on the list page as the context won’t match on an individual article.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2016-10-04 15:41:05

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: How do I make the Home page a Main Section Overview

Hello Jakob,

Thanks for your input. The article tag combo

<txp:article status="sticky" limit="1" form="intro_article" />
<txp:article form="an_article" listform="list_of_articles" limit="999" />

stopped working a couple of TXP versions ago. In 4.5.7 and some earlier versions it produces the output of both article tags, the old ‘context’ notion seems to have evaporated. I used it extensively before the update and had to go through lots of sites to amend the code. I tried the combo again on this site but got same two article tag outputs – the overview followed by the list of all the cars.

I need to get the password protection working prior to a complete redesign of the site, so don’t want to spend too much time re-engineering old code. .htaccess protection of the ‘cars’ section/directory seemed a quick and efficient way to do it but we are stuck for now. I am not seeing how to incorporate your

<txp:article_custom id="123" form="intro_article" />

suggestion.

Offline

#4 2016-10-04 20:00:27

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

Re: How do I make the Home page a Main Section Overview

joebaich wrote #301954:

The article tag combo

<txp:article status="sticky" limit="1" form="intro_article" />...

stopped working a couple of TXP versions ago

Really? I’m not aware that anything changed but maybe you need to use the listform attribute for the status="sticky" tag?

I tried the combo again on this site but got same two article tag outputs – the overview followed by the list of all the cars.

Well, that sound right for a normal use situation. If you’re on an article list page, it should show you the first sticky article in that section, then show you the list of articles in that section/category context. If you’re in an individual article context, it will display just that article without the intro. You then need to interleave it with whatever you’re using for the password protection.

If you want to use categories within a section, then IIRC that context is not recognised. Then you have to use something like <txp:article_custom section='<txp:section />' category='<txp:category />' limit="999" form="list_of_articles" /> using the tag in tag to ensure you’re in the right context.

I am not seeing how to incorporate your

<txp:article_custom id="123" form="intro_article" />...

suggestion.

I’m not sure what tag you’re using for the password protection. There’s the not-always-entirely-reliable txp:password_protect or one of the login tags cbe_frontauth or rvm_privileged, none of which I’m very familiar with. I think this is how you might do it with the built-in tag:

<txp:if_article_list>
    <txp:article_custom id="123" form="intro_article" />
</txp:if_article_list>
<txp:password_protect login="me" pass="letmein">
    <txp:article form="an_article" listform="list_of_articles" limit="999" />
</txp:password_protect>

Or you do something like this using cbe_frontauth and put the hidden content inside <txp:cbe_frontauth_if_connected>… show only when logged in …</txp:cbe_frontauth_if_connected> tags. For that you also need to provide a login mechanism.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2016-10-04 20:24:09

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

Re: How do I make the Home page a Main Section Overview

Sorry Joe,

I’ve re-read your original post and see you want to use htaccess/htpasswd to prevent access to that section altogether, so what I suggested would never come to pass because it would never show.

How about you do use a sticky article in the “cars” section as your intro article, then this in your section template:

<txp:if_article_list>

  <txp:if_category>

    <!-- category context list page -->
    <h2><txp:section title="1" />: <txp:category title="1" /></h2>
    <!-- list of articles in the current section and category -->
    <txp:article_custom section='<txp:section />' category='<txp:category />' form="list_of_articles" limit="999" sort="posted" />

  <txp:else />  

    <!-- landing list page -->
    <h2><txp:section title="1" /></h2>    
    <!-- intro article -->
    <txp:article status="sticky" limit="1" />
    <!-- link list to marques -->
    <h3>Pick a marque</h3>
    <txp:category_list wraptag="ul" break="li" parent="marques" exclude="marques">
      <a href="<txp:section />?c=<txp:category />"><txp:category title="1" /></a>
    </txp:category_list>

  <txp:if_category>

<txp:else />

    <!-- individual article page -->
    <txp:article form="an_article" />

</txp:if_article_list>

Does that do what you want?


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB