
Should I limit how many find() methods I use on a single page?
By
Brian Scramlin, in General Support
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By jds43
Hello,
Does anyone have experience with migrating content from Django to Processwire? Or are there any suggestions for achieving this?
-
By schwarzdesign
ProcessWire added the numReferences property in 3.0.107, which returns the count of all pages having a reference to the page object. However, apparently it's not possible to use this property inside a selector. I'm trying to find all pages that are referenced at least once:
$pages->find('template=service, numReferences>0'); This throws an error: "Field does not exist: numReferences".
Is there another way to filter by the number of references? Of course, I could manually filter the results of the find query, but that feels overly complicated. Ideally, I would also like to filter the number of references from a specific field; that is, find all pages that are referenced at least once in one specific page reference field.
Is there a way to do this? I guess supporting numReferences in selectors would be a feature request - if so, is it feasible?
Thanks!
-
By Brawlz
Hi,
I hope this is the correct section for my problem.
All I need is a connection to an external Database and a query gettings some data. I do this in a processwire Page-Template. I am honestly not sure if it is a problem with processwire or my code:
$host = ‚XXXXX’; $user = ‚XXXXX‘; $pass = ‚XXXXX‘; $db = ‚XXXXX‘; $port = ‚3306‘; $mydb = new Database($host, $user, $pass, $db , $port); $result = $mydb->query("SELECT * FROM char“); while($row = $result->fetch_assoc()) { print_r($row); }
Produces the following error:
Error: Exception: DB connect error 2002 - Connection timed out (in /customers/9/4/e/XXXX.de/httpd.www/wire/core/Database.php line 79)
I also tried connecting without the $port variable but got the same error.
-
By pwFoo
I played with the Selectors object and would like to use it for a special use case...
That is a custom Selectors object with dummy data converted to an php array to see the structure (Selectors object is a WireArray with "fields" added)
Array ( [0] => Array ( [0] => Array ( [field] => seg1 [value] => val1 [not] => [group] => [quote] => [forceMatch] => ) [1] => Array ( [field] => seg2 [value] => val2 [not] => [group] => [quote] => [forceMatch] => ) ) )
But instead of "seg1" the field name is "field" with value "seg1" (= my field name).
So I can't search the Selectors WireArray (= custom WireArray with added Selectors objects) with PW "find('seg1=val1')", Is there a way to search with "find()" or build a simple wrapper to make the elements searchable / filterable with find()?
-
By celfred
Hello,
I'm struggling with this : a 'group' field of 'Page' type.
The parent of selectable pages is '/groups', the template is 'group', and a member can create some groups in the /groups tree. I would like this user to see only the groups he or she has created so in my 'Find selector' in the backend, I would like to use :
template=group, created_users_id=$user->id But that doesn't seem to work... I still get the list of all available groups in the /groups tree.
Any idea ?
I had a feeling I had already seen that before (something like $user->id must be replaced by users_id or something, but I can't find anything in the Forums... and all my tests keep failing...
-