Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2020-05-03 15:00:02

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Tricky how to pass variable from form

Bloke wrote #322821:

Can you use article status? Set articles “sticky” that go in single pages and “live” for everything else? You might be able to differentiate in your article tag or just use two article tags in a single page template – one with each status attribute.

Then, as long as you only have sticky articles in single sections, it’ll output stuff from one of the article tags, and never both. They could each use different forms if you like to help differentiate the content that way (e.g. not display headings, hyperlinks, etc).

I think going forward this would be a better workflow for me, especially when the sticky articles are taken out the rss which is what you want for static pages to hide the article url, even though I manually build out my own sitemap now using a form which is fantastic functionality to have. So all static pages output correctly, then I can mark the blog page or only syndicate that and send both to Google Search Console.


…………………
I <3 txp
…………………

Offline

#14 2020-05-03 20:38:37

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

Re: Tricky how to pass variable from form

hilaryaq wrote #322816:

another solution that says if only one article exists in this section then do something would also work, as all static pages have only one article.

If you don’t actually need to test for a particular output_form being and just need to know whether a section has more than one article or not, you could also maybe test to see if there’s a second article using offset="1" to see if you get anything back:

<!-- somewhere high up on your page -->
<txp:variable name="has_multiple_articles" escape="trim">
   <txp:article limit="1" offset="1">yes</txp:article>
</txp:variable>

<!-- your regular page output -->
<txp:article …attributes…>

    <txp:if_variable name="has_multiple_articles" value="yes">
        <h1><txp:section title /></h1>
    <txp:else />
        <h1><txp:title /></h1>
    </txp:if_variable>

</txp:article>

TXP Builders – finely-crafted code, design and txp

Offline

#15 2020-05-03 21:16:42

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

Re: Tricky how to pass variable from form

And if you want to handle the heading hierarchy of the first article differently – which is not quite the same situation as you described in the first post –, you can simply flip a variable, e.g.

<txp:variable name="is_first" value="yes" />

<txp:article …attributes…>
    <txp:if_variable name="is_first" value="yes">
        <h1><txp:title /></h1>
    <txp:else />
        <h2><txp:title /></h2>
    </txp:if_variable>
    …
    rest of your article form
    ...
    <txp:variable name="is_first" value="no" />
</txp:article>

TXP Builders – finely-crafted code, design and txp

Offline

#16 2020-05-03 21:45:33

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: Tricky how to pass variable from form

Also really handy bits of code gonna test these out tomorrow too, they’ll all come in handy for different scenarios, thank you!

:)


…………………
I <3 txp
…………………

Offline

Board footer

Powered by FluxBB