-
Posts
57 -
Joined
-
Last visited
Posts posted by Sinmok
-
-
I'm trying to filter pages based on the values of one or more of their descendant pages.
Here's my tree
Project 1
Tasks folder
Task group 1
Task 1 (assigned_to_user=user1)
Task 2
Project 2
Tasks folder
Task group 1
Task 1 (assigned_to_user=user2)
Task 2
I'm trying to find all "projects" where one of the descending "tasks" assigned_to_user field = user1
So in the example above only "Project1" should return because project 2 has no tasks assigned_to_user=user1
How can I do this as efficiently as possible considering there may be 100's of projects and several thousand tasks?
I hope this makes sense!
Thanks!
-
On 7/17/2018 at 7:58 PM, ottogal said:
Have a look also to the section on Sub-selectors in that doc.
So this should do it:
$matches = $pages->find("template=group, children=[my_int_field=0]");
And for the other case:
$groups = $pages->find("template=task,parent=[closed=0]");
This does not work. The selector compiles but does not return any matches.
-
I had no idea you could reference parent and children in a selector! I'll give this a go, thanks.
-
21 minutes ago, ottogal said:
Just guessing: The second scenario should be possible with
$matches = $pages->find("template=group, children('my_int_field=0')");
I can't find any documentation on the
children('')
selector. Where did you see it?
-
Hi all,
Been a while ?
I'm trying to achieve two kinds of selectors. One to select pages based on a parents field value and one to select pages where all children match a condition.
For example, I am hoping to do something like this:
<? //I want pages of template type task where the PARENT page field "closed" = 0 $groups = $pages->find("template=task,parent-of-page.closed=0") ?>
Finally, I would like to select pages where all children follow a condition
<?php //I want pages of template type group where ALL of the pages children field called my_int_field = 0 $matches = $pages->find("template=group, children.my_int_field=0"); ?>
Are these two scenarios currently possible without iterating over a simpler selector first?
Thanks!
-
I was hoping to get some ideas on how to implement "interactive elements" within CKEditor fields.
For example, one of the requests is to be able to embed a clickable button/image that brings up a Lightbox and shows some sort of content.
Bearing in mind the majority of users editing the CKEditor fields are not at all tech savvy and barely understand what HTML is.
I know about and have used Hanna code before to solve this issue but I was wondering how else you could accomplish this sort of task?
How have you overcome these sorts of issues before?
-
Hello all,
Is it at all possible to use the new InputFieldIcon field in my own templates?
I don't see the option to select it when creating a new field.
Thanks,
- 1
-
The version was 2.3.0, I don't know if it affects newer versions.
This has most certainly affected other projects because I remember asking questions and being told has_parent was the answer, but no matter what I did, has_parent just wouldn't work. That project was using a lot of cloned pages, too..
I won't be using Page cloning any more as a safety pre-caution until we can get verification!
-
A client made the pages, so I can't be 100% certain but they do like using their page-clone tools so it is highly likely it has something to do with it.
-
Wow, that worked.
What causes this? Is there any way to prevent it / workaround?
- 1
-
Also worth noting that the following does not work either:
$p = $pages->get(1080) // returns the page I wanted $r = $p->find("") //returns empty.. //as does $r = $p->find("id>0") //also returns empty
however
$p->children //DOES return a page array
This DOES work on other pages that has children. Whaaa
-
No luck
-
I am absolutely sure they are the correct page ids.
$p = $pages->get(1080) // returns the page i want $result = $pages->find("has_parent=$p") // still empty
and produced the same result..
-
Hello,
I'm having trouble with a has_parent selector..which seems to work..only sometimes.
I've got a page tree like so (ids are made up for demo purposes)
Home Page 1 (id = 1050) sub 1 sub 2 Page 2 (id = 1080) sub 3 sub 4 Page 3 (id = 1090) sub 5 sub 6 sub 7 sub 8 sub 9
The really weird thing is that the same selector with different page id returns something unexpected..despite the only change being the page id
for example, i'm getting
$result = $pages->find("has_parent=1050") //returns a page array of 2 pages $result = $pages->find("has_parent=1080") // returns an empty page array (WHY?!) $result = $pages->find("has_parent=1090") //returns a page array of 5 pages
is there anything that could be causing the selector for page id 1080 to return nothing? the templates, access control and all that are all exactly the same
Are there any other known variables that might affect the result of a
has_page
selector?
I'm using ProcessWire 2.3.0
Edit: Basically, all I need is a PageArray of all descendants of a given page - do you know of another way of doing this?
-
Hi all,
Trying to create a simple script that iterates over each page and simply calls the save function. I've got a file called saveall.php with the following code:
<?php include 'index.php'; function sitemapListPage($page) { $page->save(); if($page->numChildren) { foreach($page->children as $child){ sitemapListPage($child); } } } sitemapListPage(wire("pages")->get("/")); ?>
This code sample is adapted from the ProcessWire sitemap plugin, but I've tried other methods and nothing seems to work.
I want to call save() as I have a beforeSave hook from a module that I want to run.
However for some reason, running this script causes me to get the follow error, on every page:
Error: Uncaught exception 'Wire404Exception' with message 'Unknown page' in /var/my_site/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module:59
If I loop through each page and print out the id/title of each page in the loop, they display fine.
Any idea what might be causing this?
I'm using PW 2.3.0
EDIT:
Never mind - figured out the error was coming from the installed module
-
PW's user system doesn't do what I need it to do, so im storing front end users as pages within my page tree. So when they login i'd need to match their u/n and pass to a page.
-
I've got a Password field on some custom pages (Not users)
How do I find these pages by the password set?
$pages->find("password=hello999");
doesn't seem to work
Cheers
-
Yeah, ideally this would all happen in the Processwire admin area.
Small module that checks roles sounds like the best approach, I'm guessing I just need to hook into Page::save and check if the template is a user, and if so, what their roles are.
-
Hello all,
Need a bit of advice.
I have a page structure where users with a specific role either can or can't view the page.
The problem is, is that I need to be able to have users who can add other users..but only assign them to specific roles.
For example:
A manager can add users and assign the roles:
Supervisor or worker
A supervisor can add users but only assign the new users with the role of worker
A worker can't add any users.
Is this currently possible to do in processwire? If not, how would you go about doing it?
-
I don't suppose there's a way to access the protected data array within the PageArray object?
-
Don't know if you can already do this, but implementing PHPs array_chunk method would be pretty useful..
For example
$list = $pages->find("template=something"); // Returns 5 pages $chunked = $list->chunk(3); print_r($chunked); /*prints*/ array( 0=> array( Page, Page, Page ) 1=> array( Page, Page ) )
Especially useful if you're trying to print pages into columns.
Can you already do this?
- 4
-
How do you clone the home page? There's no copy option. Does it have to be done via the API?
Edit: Just tried cloning the homepage and setting the clone's parent as the homepage through the API and I'm getting an error saying I can't edit the ID of a system page =\
-
Hi all,
I need to switch out which page represents the home page. I have a lot of field data in the existing home page but have been advised that the home page needs to be swapped out for another existing page.
Both pages already have a lot of data so re-doing them would take a lot of time and effort. Is there a way I can switch out the home/root page? I can't seem to move them.
Alternatively, is there a way I can copy the home page? Then I could just call $pages->get("/")->home_page->render() in the home template without losing everything I've done.
Cheers
-
What are the licensing restrictions on the CKEditor pwlink and pwimage plugins?
I'm working on a new front end editor and the only thing that doesn't work is the linking and image selecting. I reckon i could get it to work by modifying the existing plugins to work with the module I am building instead.
Am I allowed to do this? I don't see any license files
Cheers
Setting login and reset password page admin theme
in General Support
Posted
Hi all, I'm trying to figure out how to set the Admin theme for the login and reset password pages.
I copied the AdminThemeUIKit, folder from core into site/templates/modules and renamed the module and my modifications work fine once you have logged in.
The issue is that the login page and reset password pages still use the default theme under from core.
Things I've tried
All with no luck. Any suggestions?
Thanks.