Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-11-21 11:26:03

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

Using txp loop tags in plugins?

On several different sites I have made, the article list pane has got rather clogged with short posts that aren’t really major content – things like calendar events, ticker messages, slider panels etc. that are confusing the site users, especially when they have similar names (Example: there’s a main article about some course or event, then many recurring instances of that for each actual occurrence).

I was thinking about separating these out into a (some) plugin(s) so that they are not part of the article stream and also have an own list pane arranged perhaps by date /expiry status, or showing the slider image. In general, with perhaps the exception of events, they’re considerably simpler than an entire article.

Is there some way I can re-use txp’s built-in loop tags, e.g. if_first_…, if_last_…, if_different and perhaps also the new breakform setup? As far as I can tell, they’re hard-wired to the article query. Or do I need to replicate all those tags for each content type?

Also, any recommendations for ways of creating UI elements on the list/edit panes? Or plugins I could use as a case study to work from (e.g. smd_user_manager …)?


TXP Builders – finely-crafted code, design and txp

Offline

#2 2018-11-21 12:30:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: Using txp loop tags in plugins?

jakob wrote #315369:

things like calendar events, ticker messages, slider panels etc. that are confusing the site users

If your content is well sectioned, I would investigate adi_matrix. You can construct a matrix specifically for each type of content and only show the fields relevant to that as dedicated menu items under the Content menu. Makes it easier to compartmentalise, and also easy to see at-a-glance fields (such as dates or custom fields) that can all be changed at once with a single Save.

If you set the ‘Publish’ radio button, there’s also a handy pencil icon alongside each to jump to the Write panel and edit that specific article, and a new row at the bottom to create a new article stub.

There’s a beta5 floating around which is the latest for 4.7.2-dev and works well.

Is there some way I can re-use txp’s built-in loop tags, e.g. if_first_…, if_last_…, if_different and perhaps also the new breakform setup?

Not sure I get this, sorry. If you’re going to siphon off the content to another table, then no there’s no way to reuse the existing tags as far as I know. But if you keep it as article content and use adi_matrix to manage content types, you shouldn’t need to modify them.

Also, any recommendations for ways of creating UI elements on the list/edit panes? (e.g. smd_user_manager …)?

Advice: don’t use smd_user_manager: it’s a mess!

Your best bet is to look at one of the existing panels, like include/txp_link.php. That’s a fairly simple content type and uses our new Table helper class where you can throw each chunk of your table to get it to build everything. It also uses the Search/Filter classes to wire things up (note the use statement at the top of the file).

Current best practices start there. Should become much easier still when the Widget library lands in core.

Last edited by Bloke (2018-11-21 12:34:30)


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

#3 2018-11-21 19:28:23

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

Re: Using txp loop tags in plugins?

Bloke wrote #315370:

I would investigate adi_matrix. You can construct a matrix specifically for each type of content and only show the fields relevant to that as dedicated menu items under the Content menu. Makes it easier to compartmentalise, and also easy to see at-a-glance fields (such as dates or custom fields) that can all be changed at once with a single Save.

Thanks for the tip. That’s one plugin I don’t know, so I’ll investigate that.

If you’re going to siphon off the content to another table, then no there’s no way to reuse the existing tags as far as I know.

That’s what I was thinking and also what I had suspected from looking at the code. There’s no way to feed those tags the content from another query that’s not the regular article(_custom)-based query?

Advice: don’t use smd_user_manager: it’s a mess!

Pity! I was trying to think of a plugin that managed its own data.

Your best bet is to look at one of the existing panels, like include/txp_link.php. That’s a fairly simple content type and uses our new Table helper class where you can throw each chunk of your table to get it to build everything. It also uses the Search/Filter classes to wire things up (note the use statement at the top of the file).

Ok, I’ll check that. Thank you.

Should become much easier still when the Widget library lands in core.

I was thinking that could be helpful. You had got quite a long way with that as far as I recall.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB