Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2019-11-18 20:08:40

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

Re: Dev news

etc wrote #320105:

Have I mentioned we have a global evaluate attribute in 4.8?

Another excellent addition! And a great use case that will allow @bici to put cbs_category_list to rest (as mentioned here).

Should we make global trim attribute act this way too? Currently it trims list items, but does not remove the empty ones.

I reckon that’s a good idea but admittedly I can’t think of any situations off the top of my head where that might not be a good idea.


TXP Builders – finely-crafted code, design and txp

Offline

#50 2019-11-18 20:17:40

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

Re: Dev news

One more thing :-) I come up against where I wonder whether some trick might help is dealing with if_different and the first wrapping item.

Say you have something like:

<txp:if_first_article>
    <header>
        …
    </header>

    <section class="container">
        <div class="month hidden">
</txp:if_variable>
</txp:if_first_article>

<txp:if_different>
        </div>
        <div class="month">
            <txp:posted format="%B" wraptag="h3" class="month-title" />
</txp:if_different>

            <article>
                …
            </article>

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

to group articles into month containers and add the month name as a title.

If you use txp:if_first_article within txp:if_different it shows you the first and the second article as being different. So I often place the first opening div and the last closing div in the if_first/if_last but you end up with an empty div at the top (which I then hide with css). I know I can search and replace it out, but I can’t help thinking there’s a better way to avoid it.

I seem to remember that @els (?) had a complicated solution for this using a comment or variable or something, which I’ve forgotten how to do, but maybe you have something better in your arsenal of new attributes.


TXP Builders – finely-crafted code, design and txp

Offline

#51 2019-11-18 22:05:30

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

Re: Dev news

Assuming the header is exterior to articles, this should work:

<txp:article label="My parsed header" labeltag="header"
    breakby="<txp:posted format='%B' />" break="div" breakclass="month"
    wraptag="section" class="container"
>
    <txp:if_different>
        <txp:posted format="%B" wraptag="h3" class="month-title" />
    </txp:if_different>
    <article>
        ...
    </article>
</txp:article>

Note that breakby value is double-quoted, otherwise it wouldn’t work as expected.

Offline

#52 2019-11-18 22:40:55

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

Re: Dev news

Ha, that is damn clever!

I realise I’ve not got my head round breakby yet (or breakform for that matter). You did actually write it in the docs and give an example as well.

The use of double quotes feels counter-intuitive given everything we’ve learnt about tags as attributes, but I guess the reason is that in this case the expression should be evaluated and not the result of the tag?

Thanks for the tip!


TXP Builders – finely-crafted code, design and txp

Offline

#53 2019-11-18 23:03:13

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

Re: Dev news

jakob wrote #320122:

The use of double quotes feels counter-intuitive given everything we’ve learnt about tags as attributes, but I guess the reason is that in this case the expression should be evaluated and not the result of the tag?

Yes, exactly. You can avoid it by creating a monthbreak form instead

<txp:posted format="%B" />

and then calling

<txp:article label="My parsed header" labeltag="header"
    breakby="monthbreak" break="div" breakclass="month"
    wraptag="section" class="container"
>
    <txp:if_different>
        <txp:posted format="%B" wraptag="h3" class="month-title" />
    </txp:if_different>
    <article>
        ...
    </article>
</txp:article>

Or additionally create a month form

<div class="month">
    <txp:posted format="%B" wraptag="h3" class="month-title" />
    <+>
</div>

and call

<txp:article label="My parsed header" labeltag="header"
    breakby="monthbreak" breakform="month"
    wraptag="section" class="container"
>
    <article>
        ...
    </article>
</txp:article>

Offline

#54 2019-11-18 23:34:52

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

Re: Dev news

Well, I’m glad I asked that. It worked perfectly!

My situation was a bit more complex than I quoted above, especially the header, but it made it possible for me to remove most of the logic aspects out of the listform altogether, which has made things neater.

I think the expression in breakby is tolerable – easier to follow later than creating another form – but the breakform with the <+> placeholder has made it possible to keep the listform clean and re-usable for different situations: now the year view includes the breakform to wrap by month and the month view simply shows the regular listform without the wrapper.


TXP Builders – finely-crafted code, design and txp

Offline

#55 2019-11-19 08:22:32

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

Re: Dev news

jakob wrote #320124:

I think the expression in breakby is tolerable – easier to follow later than creating another form – but the breakform with the <+> placeholder has made it possible to keep the listform clean and re-usable for different situations: now the year view includes the breakform to wrap by month and the month view simply shows the regular listform without the wrapper.

Glad it works for you. It will be even more flexible in 4.8 since breakform can be made breakby-agnostic:

<div class="month">
    <txp:yield item="breakby" wraptag="h3" class="month-title" />
    <+>
</div>

Note that item functionality is delegated to <txp:yield /> now, so <txp:item /> tag is available for future use.

Offline

#56 2019-11-27 20:04:25

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

Re: Dev news

Global yield attribute for short-tags users: instead of

<txp:tag a='<txp:yield name="a" />' b='<txp:yield name="b" default="B" />' />

you can type just

<txp:tag yield="a,b" b="B" />

inside forms.

Offline

#57 2019-11-28 16:15:22

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Dev news

Since there’s a lot of traction in this thread, I’ll leave this here:

Textpattern 4.8.0 release – preflight

Extra brains and eyeballs appreciated on this issue, what else needs doing as part of the release process?

Offline

#58 2019-11-29 08:43:22

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Dev news

Bloke sifted through the dev changes since 4.7.3 and updated HISTORY.txt last night – it’s impressive!

github.com/textpattern/textpattern/blob/dev/HISTORY.txt

Offline

#59 2019-12-06 15:55:21

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

Re: Dev news

Article preview gets its own movable/resizeable modal panel, paving a way to live preview:

Offline

#60 2019-12-07 02:50:50

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

Re: Dev news

etc wrote #320386:

Article preview gets its own movable/resizeable modal panel, paving a way to live preview:

That is interesting. Those mini-tabs at the top of the page will finally disappear, maybe to be replaced with a plain link, similar to the Pages & Forms tabs?

But live preview ? Hmm, something for users with large screens and wide browser windows. Can’t imagine that being useable on my MBA. But interesting nonetheless.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB