Jump to content

Weekly update – 8 January 2021


ryan

Recommended Posts

1 hour ago, szabesz said:

I guess you meant "copied over to" instead of "uploaded to", correct?

Thx, i've corrected that in case your wording is more clear ? 

1 hour ago, szabesz said:

Anyway, I like this idea. If there was a central and configurable image browser (the image sources could be defined by the developer), so that admin users can re-use images by copying over images of a page to another page than that would help. Such a feature has its cons of duplicating the image, but on the positive side there would be no need to manage dependencies.

Exactly. Sounds good to me in your wording as well ? Not sure how the image reference field works, though. I've never found time to give it a try...

  • Like 1
Link to comment
Share on other sites

@Zeka 

Currently you can create a class like BlogPostPage and it automatically be used as the class for all pages using template "blog-post". You mentioned the PagesType class, which is used by things like Users ($users), Roles ($roles), Languages ($languages), etc. as an alternative to the $pages API var. To make sure I understand what you mean, are you saying that you'd like to be able to create a class like this:

class BlogPostPages extends PagesType {}

And then you'd get this API var ($blogPostPages) that limits itself to pages using template "blog-post":

$posts = $blogPostPages->find("date>last year, sort=date"); 

Is that what you mean, or something different?

  • Like 3
Link to comment
Share on other sites

8 hours ago, ryan said:

@Zeka 

Currently you can create a class like BlogPostPage and it automatically be used as the class for all pages using template "blog-post". You mentioned the PagesType class, which is used by things like Users ($users), Roles ($roles), Languages ($languages), etc. as an alternative to the $pages API var. To make sure I understand what you mean, are you saying that you'd like to be able to create a class like this:


class BlogPostPages extends PagesType {}

And then you'd get this API var ($blogPostPages) that limits itself to pages using template "blog-post":


$posts = $blogPostPages->find("date>last year, sort=date"); 

Is that what you mean, or something different?

Yes, something like this. Thanks.

  • Like 2
Link to comment
Share on other sites

On 1/8/2021 at 9:54 PM, ryan said:

Flexible content or page building 

One of the most common themes has been that people want more content building options as an alternative to using a rich text editor at one end, and page builder at another. This is a direction that some other CMSs have been going in (like WordPress), and one that many would like to see ProcessWire provide an option for as well.

(...)

First would be a flexible content block style editor in the core as an alternative to rich text editor that supports pluggable block types while maintaining best content management practices. If possible, we'd use an existing tool/library like editor.js or another as a base to build from, or potentially build a new one if necessary. To be clear, it would not be a replacement for CKEditor but an alternative approach supported by the core.

Please... just... don't. ?
? https://wordpress.org/plugins/gutenberg/#reviews

We've been there 3 years ago with WP. The same discussion, the same requests.
The rest is history... or rather anoying present.

I've started using PW because of its bare bone flexibility as a backend and text/content editor (not builder!).
I don't know too much about all that PW API magic (which I truly admire) and barely scratch the surface,
but that's more than enough to build a lighweight customized website with a desired design (here just customized Bootstrap + few js libraries).
I don't need and I don't want any builders for that.
Clients are extremely happy with very simplified admin dashboards and some of them ran away from Gutenberg and other WP builders last year.

I'm perfectly aware that there are different clients, developers, trends and expectations.
I just feel (and see) that we're overcomplicating and overbuilding websites (and tools) these years...
Just sighing, Guys...

All the best to Ryan and the whole PW Community in 2021!

  • Like 1
Link to comment
Share on other sites

I know some things I have struggled with in the past is exporting fields from one website to another to jump start a project, and option fields can't be imported in.  I have to go to each of, say 20 fields, and manually copy and paste all options in for all of them. 

When I am working in a page backend in one tab, and have another tab open with the front end to see my changes, I can save the backend tab, and instead of staying where it is at, it shoots me to the top of the page.  This isn't great.  Would prefer it to stay there so I can tweak, save, tweak, save.  Most other backend system I don't even need to hit save as changes I am making are live, but this is a step in the right direction!  Also would be nice to have a way to not have to switch back and forth between tabs.

Getting live editing would be even better!  I even purchased the plugin for this and wasn't a huge fan of it.

  • Like 2
Link to comment
Share on other sites

54 minutes ago, Chris Ernovsky said:

Please... just... don't. ?
? https://wordpress.org/plugins/gutenberg/#reviews

We've been there 3 years ago with WP. The same discussion, the same requests.
The rest is history... or rather anoying present.

I've started using PW because of its bare bone flexibility as a backend and text/content editor (not builder!).
I don't know too much about all that PW API magic (which I truly admire) and barely scratch the surface,
but that's more than enough to build a lighweight customized website with a desired design (here just customized Bootstrap + few js libraries).
I don't need and I don't want any builders for that.
Clients are extremely happy with very simplified admin dashboards and some of them ran away from Gutenberg and other WP builders last year.

I'm perfectly aware that there are different clients, developers, trends and expectations.
I just feel (and see) that we're overcomplicating and overbuilding websites (and tools) these years...
Just sighing, Guys...

All the best to Ryan and the whole PW Community in 2021!

I dont think anyone here is wanting gutenberg.  Take a look at this video.  Its basically just the PW backend in a side window instead of full page so you can see what you are editing while you are editing.  That way you dont scroll down to a box, save, get shot back up to the top, switch tabs, hit refresh.  All that is wasted time.  You just edit the box and see the changes.

Now, once the editing experience is updated, I think it would be nice to be able to have 2 sets of children for each page.  One for the page path/child pages/url, and one for the design rows/sections on that page. 

So the tree would have a page path mode, and a page design mode that shows children of the page, based on the mode you are in.  In the design mode, children of that page would be rows on the page, path mode would be child pages.

ie. When I edit a Category page in path mode, maybe it has a text field for Page Title and Page Description, which have nothing to do with design, and its children are the products in that category. 

If I edit that same category page in page design mode, the first child page is called Intro Section, and has fields for design related settings for that row.

I think this would be the best approach becuase the api would have a clear support for adding fields for both view modes, but not force anyone to use anspecificic front end framework or theme.  It would be nice to have a slider field time for font sizes. 

  • Like 2
Link to comment
Share on other sites

Better private pages for note-taking, intranets, extranets: I happen to use ProcessWire as public as well as a private note-taking tool. While ProcessWire works really well as a public website, the private website is harder.

  • As a webmaster I want to protect the entire site, a branch (root page and it's children) or a page so that I know my page(s) stay private. Much like Adrian's Page Protector module.
  • As a webmaster I want the page tree to show if a page is protected so that I don't worry if it's protected.
  • As a webmaster I want page protection to be built-in and work with Page Status.
    page-status.png.687c6020a4c73de76bcb28c76c3a74b6.png
  • As a web designer I want to present public pages to visitors and public+protected pages to permitted users.
  • As a webmaster I want to grant access / permission to specific users and roles.
  • As a webmaster I want to ensure that private / protected pages stay private. Today I might easily publish a page by mistake (when using Unpublished status to control private pages):
    publish-btn.png.baaa4e56d6b5a4e00c70242fd02a23d4.png

Benefits: This change will make ProcessWire attractive in a whole new game (intranets, extranets, note-taking, private online knowledge-bases and much more).

  • Like 2
Link to comment
Share on other sites

9 hours ago, joer80 said:

I think it would be nice to be able to have 2 sets of children for each page.  One for the page path/child pages/url, and one for the design rows/sections on that page.

Interesting approach. It deserves further investigation, I think. If I understand it correctly, you propose another set of children – separated from the current set – which is used for layout only perhaps?

10 hours ago, Chris Ernovsky said:

some of them ran away from Gutenberg and other WP builders last year.

Reading other's comments, I think most of us do not ask for a "Gutemberg only like" feature, instead, most of us need a way to implement a builder which is similar to the current repeater(matrix) based solutions others have presented in the forum, but geared towards layout + building.  Editor.js could simply be another fieldtype, just an alternative to CKEditor. You and/or your client could decide which one to build upon your "RTE editing needs".

  • Like 3
Link to comment
Share on other sites

11 hours ago, Chris Ernovsky said:

Please... just... don't. ?
? https://wordpress.org/plugins/gutenberg/#reviews

We've been there 3 years ago with WP. The same discussion, the same requests.
The rest is history... or rather anoying present.

I've started using PW because of its bare bone flexibility as a backend and text/content editor (not builder!).
I don't know too much about all that PW API magic (which I truly admire) and barely scratch the surface,
but that's more than enough to build a lighweight customized website with a desired design (here just customized Bootstrap + few js libraries).
I don't need and I don't want any builders for that.
Clients are extremely happy with very simplified admin dashboards and some of them ran away from Gutenberg and other WP builders last year.

I'm perfectly aware that there are different clients, developers, trends and expectations.
I just feel (and see) that we're overcomplicating and overbuilding websites (and tools) these years...

Just my five cents (or fifty, looking at the length of this answer):

There is zero interest here to move ProcessWire away from what it does now, or somehow get rid of the way it handles structured data. Absolutely zero. If you're worried that someone wants to thrash the system we now have and replace it with a Gutenberg clone, fear not: that will not happen, period.

Now, as you've pointed out, there are different use cases. Almost all the sites I build and clients I work with nowadays require a "builder" approach: flexibility in terms of laying pages out. CKEditor goes to some extent here, but it's riddled with issues, and honestly the experience can be pretty horrendous: image management in particular is a lacklustre, and embedding any type of dynamic content (or anything CKEditor doesn't handle itself) gets difficult/technical (short codes with params etc.)

A couple of reasons why comparing what we're doing to what WP is doing with Gutenberg makes little sense:

  • In WordPress Gutenberg is going to replace the "classic editor", and it's also going to replace a lot of other built-in tools (such as menu management GUI) in the long term. The ultimate goal there is a "full site editor". This has very little to do with what we're discussing here.
  • WordPress has never (natively) provided custom fields. Instead they have predefined fields and (freeform) page meta. ACF and similar plugins that make custom fields possible are popular, but page builders are even more so. It makes sense for the core team to extend the core with the tools that most users seem to want.

I could get into the reasons why Gutenberg reviews are so bad — such as there being a lot of history, a lot of resistance to change, a lot of misunderstanding, likely mostly developer votes while the feature itself is aimed more at content editors, and so on — but I won't.

My point is that improving the ability of ProcessWire to handle flexible layouts is not going to take anything away from those who don't want or need that. ProcessWire has many things that some users don't need or use. For an example, I've never used front-end editing for client sites. It's a feature I don't need, so I don't use it. It's as simple as that ?

52 minutes ago, SwimToWin said:

Better private pages for note-taking, intranets, extranets: I happen to use ProcessWire as public as well as a private note-taking tool. While ProcessWire works really well as a public website, the private website is harder.

  • As a webmaster I want to protect the entire site, a branch (root page and it's children) or a page so that I know my page(s) stay private.

I'm going to cherry-pick one thing from this list: "I want to protect the entire site" ?

I've worked on many completely non-public sites. While I believe I get the reasons @ryan has for not allowing the home page to be non-public, I would absolutely love for this to change. Even if it required a hook or config setting, that'd be a very nice addition. Currently I'm doing this with custom code, but there are some negative implications and I'm always a bit worried that it'll break: first of all it's (my) custom code and if something changes there's always a slight possibility that it won't work as expected, and second of all it needs to be done with hooks (to protect assets and make sure that nothing can interfere) and can thus sometimes get a bit complicated.

TL;DR: if there was an option to somehow protect the entire site so that all non-authenticated requests (home page included) result in a login request, I'd be one happy user ?

  • Like 11
Link to comment
Share on other sites

16 minutes ago, teppo said:

TL;DR: if there was an option to somehow protect the entire site so that all home page requests result in a login request, I'd be one happy user

Is it in the requests repo yet? If not, if you add it I'm happy to give it a thumbs-up ?

From now on, GitHub thumbs-ups are the way to go: 

 

Ryan says: "Please use the thumbs-up votes on GitHub for issue reports and feature requests that you value the most, and going forward, that will help us to cover them in a useful order."

I guess it also means we should not use the heart or any other positive looking reaction as GitHub seems to be able to sort on one reaction only, that is why it is only useful to stick to thumbs-up.

 

  • Like 3
Link to comment
Share on other sites

36 minutes ago, szabesz said:

Is it already in the requests repo? If not, if you add it I'm happy to give it a thumbs-up ?

From now on, GitHub thumbs-ups are the way to go:

I have a lot of thumbs-upping to do... ?

Anyway, I couldn't find related request right away. I know this has been requested and discussed on various occasions but I assume it's not such a common need that anyone would've yet opened a request for it in the "new" repository, or perhaps those asking about it here or googling for this found an earlier answer and figured that it'll be unlikely to change.

Here's a new request: https://github.com/processwire/processwire-requests/issues/376.

  • Like 6
Link to comment
Share on other sites

6 hours ago, teppo said:

There is zero interest here to move ProcessWire away from what it does now, or somehow get rid of the way it handles structured data. Absolutely zero. If you're worried that someone wants to thrash the system we now have and replace it with a Gutenberg clone, fear not: that will not happen, period.

This is EXACTLY what I had to hear. Thank you! ??

I'm open to any new approaches and improvements with .js editing/building as an option.
Just don't want to lose my new, beloved home... ☺️

  • Like 3
Link to comment
Share on other sites

24 minutes ago, SwimToWin said:

Sometimes, webmaster might choose to use a set of fields as "Page Title" and so it makes sense to loosen the data model and change the Page dependency on Title field from standard to optional.

The title field is already optional. You just need to make it non-global by editing the Title field and unchecking the Global checkbox on the Advanced tab. Then you can remove it from any templates where you don't need it.

If you want to see the values of other fields (instead of Title) in Page List you can set that on the Advanced tab when editing the template.

2021-01-17_100140.png.96727ba8c537cf84a2451ab9c40dee93.png

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

I use PW on multiple websites that I admin and write content for. I'm therefore often updating my PW sites, either by writing new content (most commonly) or doing template coding, or coding other features such as logic-specific ad display. Based on my experiences across all my websites, here are my thoughts on the OP topics:

Flexible content or page building - I've never needed it and can't see myself using it in the future. I already have a few things set up like footer content where I write footer-left, footer-middle, footer-right content as the body of non-templated pages, and I simply code my footer to display the body content of those 3 pages using what's already in the PW core and API. Easy, and perfect.  I don't see any need for anything beyond that, such as flexible content or page building (for my purposes at least). I absolutely love the CKEditor ? and I'm not sure why or what use case anyone would want for a block editor (in fact, a block editor is a reason why I moved away from WP to PW - the WP block editor was slow and frustrating and I could achieve way faster content creation with PW). I have a few page templates where there are multiple "body" contents, and I simply use additional "body" style fields in those templates. I understand the PW CKEditor is not going to be replaced, so I'm not worried there, but I'm not doing anything that ever needs more than defining fields and displaying them with a template.

Admin theme improvements - a really quite massive "pain point" for me across all my sites is the inability to order the page tree in PW admin in a way other than the default ?. When you have 90+ pages of content (which I do on several of my sites and hope to on the others later), not being able to specify a default order is very frustrating. Sure, for a 20-page site, no big deal. For anything more, it's quite hard. In particular, I'd like these 2 features: It seems both features exist, although I'm struggling to find a way to combine them.

  1. The ability (or the default) to be most recently created page at top (not the oldest created page which it seems to default to - it's basically in the reverse order of what I want.) And yes, there is the "recent" menu available in Admin, but that's not as helpful as you might think. [SUBSEQUENTLY EDITED - This feature already exists in the core! - see comment below by @adrian ]
  2. The ability to put some "sticky pages" always at the top of the page tree. For me, this would be regarding specific to ads I want to show/edit frequently, but I expect there are other people with other use cases who want certain pages to always appear at the top of the page tree. This feature is of equal or higher importance to me than changing the default order. [SUBSEQUENTLY EDITED - This feature exists in the AdminOnSteroids module - see comment below by @adrian - however, I am not sure whether or not this feature can be used with a specified sort order as mentioned in the previous point]

File/media manager and more file sharing options - Yes, BUT ONLY if we can somehow specify a different alt field for an image each time that a central image is used in a new page. If that's not possible, then I'd rather stay on the default of having to re-upload the same pic separately for different pages (which is what I'm doing now anyway). For me, it's crucial that the image if used freshly in a new page, has a fresh image alt tag. Because you might want to re-use the same pic for slightly different reasons in each case.

External file storage - I don't use this and can't see myself ever using this, although I can see how others might want it. I purposely like having everything on one host/location.

Live preview and auto-save:

  • Auto-save is certainly nice, but ONLY IF it does not over-ride a user-specified save. I sometimes change page content around, but then decide I don't want those changes, so I purposely don't save it. In this case, auto-save could cause me big problems if it saves the page when I did not want it to. On the other hand, I've lost content before by my own fault, by forgetting to save and then going away and my session timed out after I came back. So I certainly could use autosave as long as it saves the page in another location so as not to overwrite an existing page.
  • Preview options are already very rich, with "new tab" and "modal" options that I use frequently, so I cannot see a use for live preview for my use cases. The existing previews are pretty amazing already!

That's it from me.  All of that said, I love PW, and admin-ing my sites is a breeze thanks to PW and its wonderful community of people!

Edited by Violet
strikethru on features that already exist
  • Like 3
Link to comment
Share on other sites

5 hours ago, Violet said:

The ability (or the default) to be most recently created page at top (not the oldest created page which it seems to default to - it's basically in the reverse order of what I want.)

Just in case you don't know, you can do this via the parent page template's Family tab > Sort settings for children

5 hours ago, Violet said:

The ability to put some "sticky pages" always at the top of the page tree. For me, this would be regarding specific to ads I want to show/edit frequently, but I expect there are other people with other use cases who want certain pages to always appear at the top of the page tree.

This is possible with the AdminOnSteroids module's AddNewChildFirst option which allows you to maintain manual sorting, but automatically putting new pages on top.

BTW - not suggesting that something like this shouldn't be in the core - just hoping to help you out with a solution now.

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

On 1/12/2021 at 3:10 AM, ryan said:

Most likely I wouldn't be able to make any more commits to the core if I got run over by a train. I've always thought this was one of the reasons to use open source, ensuring that when someone smacks the tracks, the code doesn't. But it's not just about being open source, the code also has to be clean and well documented so that others can easily take it on board. That's one reason why I put so much effort into code quality and code documentation. My intention is that the code is always ready for others to understand and work with. As for commercial services/modules, it's the same risk inherent with any product or service you pay for. While not open source, the Pro modules do have the same code quality and documentation as the core, and are not obfuscated or encrypted. If it sets your mind at ease, I'm 46 years old (not 76), and am very healthy. I run and lift every day, eat lots of salads, don't eat red meat, and don't participate in any dangerous activities. Most likely I'll be here for at least another 46 years. But if I'm ever derailed then I know the project would still be in good hands.

46 you're still young Ryan ? I'm 66 this year and active as a martial arts instructor, and I still want to do it for the next 20 years hopefully.

So you can maintain PW for the next 40 yrs. ?

  • Haha 1
Link to comment
Share on other sites

21 hours ago, adrian said:

Just in case you don't know, you can do this via the parent page template's Family tab > Sort settings for children

Oh thank you!! ? Can't believe in all this time that I never thought to look there! ? I tried it out now with one of my sites and it worked! I love the range of options and reverse sort being available. Whew! That's probably my biggest PW problem and turns out the solution was already in the core all along. A huge thank you! This is why I love the wonderful community here.

  • Like 1
Link to comment
Share on other sites

@Violet - just a reminder that with AOS as I mentioned, point #2 is also possible - you edited your post to note that #1 is possible, but I want to make sure you understood that #2 also is (even if it does require a module). AOS is essential on all installs in my opinion - I don't use many of its features, but there are a few I really appreciate.

Link to comment
Share on other sites

On 1/23/2021 at 9:41 PM, adrian said:

@Violet - just a reminder that with AOS as I mentioned, point #2 is also possible - you edited your post to note that #1 is possible, but I want to make sure you understood that #2 also is (even if it does require a module). AOS is essential on all installs in my opinion - I don't use many of its features, but there are a few I really appreciate.

Thanks so much for the info! I have been testing out AOS for this purpose, which I had actually not used before. I have been struggling with trying to combine AddNewChildFirst with a previously specified sort order on the parent page. Hmm. Either it's not possible, or it's not obvious to me. I have been playing around with it but can't quite seem to do it. I have read the documentation at https://github.com/rolandtoth/AdminOnSteroids/wiki/AddNewChildFirst but I don't quite understand. It says "Unlike setting the sorting on the parent page this tweak enables manual sorting afterwards." But I don't know if that means it IS, or IS NOT, compatible with setting sorting on the parent page. If you or anyone else has any advice, I would be eager to try again. I'm probably doing something wrong but I don't know what.....!

I'll explain my use case, which I imagine would be a not-uncommon one:

A blogger (me) has a PW site with around 100 pages with a very flat structure. The vast majority of the 100 pages are a direct child of the home page, with very few having child pages themselves. This blogger wants to sort pages by reverse creation date so newest page is at top of page tree, which thankfully I learned from adrian's earlier comment was possible through setting sorting on parent page. Yay!! But I ALSO want to make a few pages (the ones that contain ad units that need to be updated more often) always stay at the top of that same page tree. Ad unit template is different from other pages, if that helps, but even when I set AddNewChildFirst to apply to ad unit template, it still won't allow me to move the ad unit pages to the top of the tree due to my previously specified sort order. (I do not want to manually drag and drop sort order for these 100+ pages. )

So what I'm asking overall is, is it possible to specify that the page tree get sorted first by any pages labelled as "sticky pages" always at top of tree, then the remaining pages by reverse creation date? I've updated my main post further up to mention AOS AddNewChildFirst and to reflect where I'm currently at with this.

Link to comment
Share on other sites

In the parent page you have to set the sorting to manually drag. DO NOT set any hard sort order there. Then you can use the add new childs first method from AOS. This results into the following behave:

Everytime you add a new child to that parent page, it is added on top of the list, as first child under the parent. From there on, you can drag and sort this and all other pages manually as you like.

  • Like 1
Link to comment
Share on other sites

On 1/26/2021 at 3:54 AM, Violet said:

So what I'm asking overall is, is it possible to specify that the page tree get sorted first by any pages labelled as "sticky pages" always at top of tree, then the remaining pages by reverse creation date?

There's no built-in option for that, but nearly everything is possible in PW with hooks and some lateral thinking. ?

Below is one way you could achieve the goal. In my example I'm using "country" pages under a "countries" parent but the same idea will work for your case of children under the home page.

Create a "multiple pages" Page Reference field named "top_pages" and add it to the template of the parent page. The field should be limited to the selection of child pages, so in "Selectable pages" set the "Selector string" option like this:

2021-01-28_104823.png.941331b5141ec365c884d197489febde.png

Here "page" is a special keyword that means "the page that is currently being edited".

Now edit the parent page and select the child pages you want to be sorted at the top.

2021-01-28_105326.png.371403016a3a59838dcfd2df49bde963.png

On the Children tab I have this:

2021-01-28_105427.png.dd4563c79aa3eec67764d790ba30f3ee.png

So I want the children sorted by title, apart from the children selected in the top_pages field.

In /site/ready.php I have the following hooks, which affect the paginated listing of child pages in ProcessPageList:

// Before ProcessPageList::find
$wire->addHookBefore('ProcessPageList::find', function(HookEvent $event) {
	$selector_string = $event->arguments(0);
	$parent = $event->arguments(1);
	// Return early if the parent page doesn't include the top_pages field, or if the field is empty
	if(!$parent->hasField('top_pages') || !$parent->top_pages->count) return;
	// Convert selector string to Selectors object to make it easier to examine and modify
	$selectors = new Selectors($selector_string);
	$start = $selectors->get('field=start');
	$limit = $selectors->get('field=limit');
	// Return early if Selectors object does not conform to what is expected for some reason
	if(!$start || !$limit) return;
	// Get start and limit as integers
	$start_value = (int) $start->value;
	$limit_value = (int) $limit->value;
	if($start_value === 0) {
		// This is the first pagination
		// Reduce the limit by the count of the top pages
		$limit->value = $limit_value - $parent->top_pages->count;
		// Set a custom property on the ProcessPageList object
		// to indicate that the top pages should be prepended to the children
		$event->object->add_top_pages = true;
	} else {
		// This is not the first pagination
		// Reduce the start by the count of the top pages
		$start->value = $start_value - $parent->top_pages->count;
	}
	// Set the selector string argument to the string value of $selectors
	$event->arguments(0, (string) $selectors);
});

// After ProcessPageList::find
$wire->addHookAfter('ProcessPageList::find', function(HookEvent $event) {
	$parent = $event->arguments(1);
	// If there are top pages to add...
	if($event->object->add_top_pages) {
		// Prepend the top pages to the children
		$children = $event->return;
		$children = $parent->top_pages->add($children);
		$event->return = $children;
		// Unset the custom property now that the job is done
		unset($event->object->add_top_pages);
	}
});

Result:

2021-01-28_112933.png.2287a2b18ddad713e757c43f39899032.png

Note: with this approach you must not select more "top pages" than the pagination limit for ProcessPageList (the default is 50).

Edited by Robin S
Updated hook code for more robust selector parsing
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
On 1/11/2021 at 5:10 PM, ryan said:

I will update the AdminThemeUikit repo. Unfortunately I've run into some npm error where it wants to do some kind of updates before it will update the UIkit version, but updates it wants to do in npm fail. This seems to happen every time I want to update something that uses npm, but I always eventually find a way around it. This last one has had me stuck for awhile though. I'll revisit it here soon. I've never liked these command line package installers/managers because they always seem to have some problem without a clear answer. I guess it's the nature of the beast.

I am willing to help with that. I also know the pains of npm, but also know (sometimes) how to tackle them.

  • Like 1
Link to comment
Share on other sites

At the risk of derailing this thread, here is the simplest way I know to get sticky pages in the admin page tree. @Violet

1. Set up a checkbox field called “sticky”.

2. Add this hook at the top of /templates/admin.php (since it’s admin specific, but ready.php will work, too):

$this->addHookBefore("ProcessPageList::find", function(HookEvent $event) {
    $selectorString = $event->arguments('selectorString');
    if ($event->arguments('page')->sortfield() === 'sort') //if manual sorting is on for the children of this page, don’t do anything.
        return;

	//just add your checkbox to the start of the selector. it will sort by this first, and additionally by the usual sort field.
    $event->arguments('selectorString', 'sort=-sticky, ' . $selectorString);
});

3. Check the sticky box on pages you want to see at the top.

It might make sense to make the field global, but the selector won’t care even if a page doesn’t have it. Or rather, Ryan probably went to great lengths to handle such cases ?

  • Like 3
Link to comment
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...