Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-05-03 14:56:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,328
Website

Re: Tricky how to pass variable from form

hilaryaq wrote #322816:

all static pages have only one article. The logic that every section page is an article list is what’s effecting it, if I could somehow mark ‘static’ page articles as individual article not article list pages it would be an easy solve too!

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/form or just use two article tags in a single page template – one with each status attribute, one directly after another.

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).

Last edited by Bloke (2020-05-03 14:57:46)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2020-05-03 14:57:21

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

Re: Tricky how to pass variable from form

Bloke wrote #322820:

Ah, drat. I hoped it’d work. Well you can probably cheat:

Step 1. In your article form:

<txp:if_custom_field name="override_form" not value="page_single">...

Step 2. In your page template:

<txp:hide process="2">...

It worked!

<txp:hide process=“2”> <txp:if_variable name=“multi_page” value=“1”> <h1><txp:section title=“1” /></h1> </txp:if_variable>
</txp:hide>

I’m outputting the section title in a h1 with this now, so that the article list underneath can take h2’s, working perfectly thanks so much Stef you’re a genius!! Delighted. :)


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

Offline

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

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 263
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: 3,810
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: 3,810
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: 263
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