Jump to content
bernhard

Inputfield to choose visibility of a widget on certain pages?

Recommended Posts

Hi,

there has been some discussion about widget systems using ProcessWire: https://www.google.com/search?q=site:processwire.com+widget+system

When working with widgets, you'll need to define somewhere WHERE the widget is visible and where it is not. The first thought might be: Let's use a Page Reference field for that! But there is a problem: What, if you want to show the widget on all "blog" pages? That's not possible with that Inputfield. OK, second thought might be that we can do that using the Selector Inputfield:

WRxWlJE.png

The problem: This would mean "template=blogitem|clubs|event, parent=/presse" which only shows 2 blogitems that live under /presse, which is not what I want, because I'd need an OR condition for all rows... Besides I think this Inputfield is too complicated for non-tech users.

What I've done in 2017 is this: (https://processwire.com/talk/topic/8635-simple-example-for-widget-management/?do=findComment&comment=148216)

widget.gif

This post got 3 likes - I'd like to get your feedback on that approach, because I might need something similar on a current project and I'm not sure if that 3 likes mean "useless" or "overengineering" or similar... I'm thinking if that's maybe also too much for a regular webmaster and I should just create a simple text Inputfield to write a custom selector into (done by superuser)?!

How are you solving this? What do you think of the ui shown in the screencast? Is that inutitive? Worth putting it into a module?

 

  • Like 1

Share this post


Link to post
Share on other sites

As far as UI is concerned, in your example, when you disable all children and then enable a single child, the parent should reflect the selected items as enabled. As it is, if the parent were collapsed, you would have no visual indication that one or more children were enabled.

 

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, rick said:

As far as UI is concerned, in your example, when you disable all children and then enable a single child, the parent should reflect the selected items as enabled. As it is, if the parent were collapsed, you would have no visual indication that one or more children were enabled.

That's a good input, thx. That would mean we'd need some kind of "not visible on that page, but on at least one descendant"...

Share this post


Link to post
Share on other sites
14 minutes ago, bernhard said:

That would mean we'd need some kind of "not visible on that page, but on at least one descendant"...

Two options come to mind; 1) Use a tri-state indicator to convey "All Selected", "None Selected", or "Partial Selected", or 2) Use some type of numeric flag to indicate the number of selected children.

A combination of both is similar to the way most windows installer programs work when you select children of a parent to be included in the install.

Share this post


Link to post
Share on other sites

I like that approach. Looks great and quite intuitive for the user.

Reminds me of old Joomla days. There is a similar page-tree style thing that lets you choose where widgets (in Joomla speak: modules) should show.

It would be great if the user could also choose on every page which widgets to show. Like a 2-way thing: in the widget you choose the pages. In the page you choose the widgets. That way you don't have to jump around the page tree to select widgets for pages.

I'd definitely be interested in such a inputfield (combination).

  • Like 2

Share this post


Link to post
Share on other sites
16 minutes ago, gebeer said:

Reminds me of old Joomla days.

I built it 2017, so that's totally possible that I had some Joomla UI in my head 😄 

 

13 minutes ago, gebeer said:

Like a 2-way thing: in the widget you choose the pages. In the page you choose the widgets. That way you don't have to jump around the page tree to select widgets for pages.

I get your point, but I guess that would get very complicated... We'd need a complete UI for widget management. At the moment those widgets in my setup are pages and I only need one inputfield to handle visibility. Imagine the other direction: We are on the frontpage and want to let the user choose the widgets there... Which widgets do exist? If the user sets the widget visible, what about child pages (eg on blog overview page, what about the detail pages?). How to add a new widget to the page?

Hmm... Maybe a quite simple field would be enough:

Widgets visible on this page: W1, W2, W3
Other available widgets: W4, W5, W6

The widgets could be links that open the widget edit screen in a panel. Simple enough. But thinking about that, the next step would be some way of defining WHERE the widget should live on that page. Including some way to define the position/sort order... That's quite how modules in Joomla worked (at least until 2014). I think, a Widget Management Module would make the most sense... But then we would need some kind of frontend companion. I guess that's not how PW works?! Or at least it does not shine in that regard as much as it does elsewhere...

Share this post


Link to post
Share on other sites
2 minutes ago, bernhard said:

The widgets could be links that open the widget edit screen in a panel. Simple enough. But thinking about that, the next step would be some way of defining WHERE the widget should live on that page. Including some way to define the position/sort order... That's quite how modules in Joomla worked (at least until 2014). I think, a Widget Management Module would make the most sense... But then we would need some kind of frontend companion. I guess that's not how PW works?! Or at least it does not shine in that regard as much as it does elsewhere...

What do you mean by frontend companion? Should frontend vistors be able to choose widgets?

Most of the times I don't really need a sophisticated widget system. So far working with page fields solved my needs. In my widget templates I have select fields for the widget position. You'd need a repeater field to define different positions on different pages. To pack the positions into your inputfield would sure be difficult while having good UX at the same time.

The widget management module would definitely be very useful to get an overview.

7 minutes ago, bernhard said:

Hmm... Maybe a quite simple field would be enough:

That should do it.

Share this post


Link to post
Share on other sites
6 minutes ago, gebeer said:

What do you mean by frontend companion?

Disregard that. I thought Joomla had a standard way of defining module positions. But that seems to be different for every template. The backend would nevertheless have to know which positions are available to choose from for the frontend 🙂 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...