Jump to content

hellomoto

Members
  • Posts

    364
  • Joined

Everything posted by hellomoto

  1. Thank you, I tried removing the method & without DatabaseQuerySelectFulltext, but when searching for field='' no results are returned (nor if searching by subfield). Is there no way to reorder the where to be included after the leftjoin when returning this: $query->leftjoin("$table AS $_table ON $_table.pages_id=pages.id")->where("$_table.pages_id IS NULL"); return $query; ? The where clause precedes the left join in the join clause before it that includes it? ... JOIN field_list AS field_list ON field_list.pages_id=pages.id AND ((((field_list_li1.pages_id IS NULL) ) )) LEFT JOIN field_list AS field_list_li1 ON pages.id=field_list_li1.pages_id AND (field_list_li1.pages_id IS NULL) WHERE ...
  2. This returns all values (don't know how as I thought I'd tried it already and been getting nothing but errors): if ($subfield === 'data' && $value === '' && $operator === '=') { // return pages with no data? static $n = 0; $_table = $table . '_li' . (++$n); $query->leftjoin("$table AS $_table ON pages.id=$_table.pages_id AND ($_table.pages_id IS NULL)"); return $query; } so no error... but ineffective... If I insert $ft = new DatabaseQuerySelectFulltext($query); $ft->match($table, 'pages_id', $operator, 'NULL'); first within the above condition, there are no results, and getQuery returns SELECT LEFT JOIN field_list AS field_list_li1 ON pages.id=field_list_li1.pages_id AND (field_list_li1.pages_id IS NULL) WHERE field_list.pages_id=:pf21s0X so the would-be where gets appended (I tried with value='IS NULL' also?), but what is the code that it outputs? :pf21s0X?
  3. If I run this in DB it works SELECT pages.id, pages.parent_id, pages.templates_id FROM pages LEFT JOIN field_list ON pages.id=field_list.pages_id WHERE /*(pages.templates_id=124) AND */(field_list.pages_id IS NULL) I can't figure out how to implement it in getMatchQuery.
  4. Also tried (from fields in core): static $n = 0; $_table = $table . '_li' . (++$n); $query->leftjoin("$table AS $_table ON $_table.pages_id=pages.id"); $query->where("($_table.pages_id IS NULL)"); return $query; Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_list_li1.pages_id' in 'on clause' Whole query: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_list AS field_list ON field_list.pages_id=pages.id AND ((((field_list_li1.pages_id IS NULL) ) )) LEFT JOIN field_list AS field_list_li1 ON pages.id=field_list_li1.pages_id AND (field_list_li1.pages_id IS NULL) WHERE (pages.templates_id=124) AND (pages.status<1024) GROUP BY pages.id ORDER BY pages.created DESC LIMIT 0,25 -- [0.8ms] FAIL SQLSTATE[42S22] So on line 3 before the AS comes in the AS pops up... With $_table = $table: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'field_list' getQuery(): SELECT LEFT JOIN field_list AS field_list_li1 ON pages.id=field_list_li1.pages_id WHERE (field_list_li1.pages_id IS NULL)
  5. Thank you much. Here is the schema: public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = "VARCHAR(21) DEFAULT ''"; // empty placeholder, required $schema['sf1'] = "CHAR"; $schema['sf2'] = "INT UNSIGNED"; return $schema; } I added this now to getMatchQuery: if ($subfield == 'data' && empty($value) && $operator == '=') { // return pages with no data? $query->leftjoin($table)->where("IS NULL {$table}.pages_id"); return $query; } but in Lister get this error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NULL field_list.pages_id ) )) LEFT JOIN field_list WH' at line 3 It looks as though this is the SQL query: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_list AS field_list ON field_list.pages_id=pages.id AND (((IS NULL field_list.pages_id ) )) LEFT JOIN field_list WHERE ((pages.parent_id!=2 AND pages.parent_id NOT IN (SELECT pages_id FROM pages_parents WHERE parents_id=2 OR pages_id=2))) AND (pages.status<8192) GROUP BY pages.id ORDER BY pages.modified DESC LIMIT 0,25 -- [0.2ms] FAIL SQLSTATE[42000] Thanks @ryan
  6. public function getMatchQuery($query, $table, $subfield, $operator, $value) { if (!$subfield) $subfield = 'data'; // search for empty/not empty: if ($subfield == 'data' && empty($value) && $operator == '!=') { // doesn't work for '=', same result $ft = new DatabaseQuerySelectFulltext($query); $ft->match($table, 'sf1', $operator, $value)->match($table, 'sf2', $operator, $value); return $query; } if ($subfield == 'data' && empty($value) && $operator == '=') { // return pages with no data? } } Presently it returns all pages where field in question is populated, whether searching for empty or not empty. When field value is empty, there is no row representing it in the field table. How can I return those pages when searching `fieldname=''` if the page template has the field? EDIT: I replied to this myself with details of issues I encountered trying to resolve it but essentially I can't figure out how to have the "where" method added to the query added ultimately AFTER the left join. The left join is aliased (or error that it isn't unique), but the where statement included with/after it always is included in the whole statement in the JOIN preceding the LEFT JOIN where the alias is introduced. static $n = 0; $_table = $table . '_li' . (++$n); $ft = new DatabaseQuerySelectFulltext($query); $query->leftjoin("$table AS $_table ON $_table.pages_id=pages.id")->where("$_table.pages_id IS NULL"); return $query; Resulting Lister query: SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_list AS field_list ON field_list.pages_id=pages.id AND (((field_list_li1.pages_id IS NULL ) )) LEFT JOIN field_list AS field_list_li1 ON field_list_li1.pages_id=pages.id WHERE (pages.templates_id=124) AND (pages.status<1024) GROUP BY pages.id ORDER BY pages.created DESC; so if that would-be WHERE AND clause preceding the LEFT JOIN would just come after it instead, it should work, but how?
  7. Are URL segments indexable & search engine optimizable? Site-mappable? With or without SEO meta tags rendered in the native site template rendering the URL segment, drawing page data from a separate PW installation? if only rendering when the urlSegment1 matches the name of a page of a specified template with the same parent? I don't know how to test this locally. Thank you.
  8. Disabling textformatters: FieldtypeSomething > init() > parent::allowTextFormatters(false); Making the pattern readonly: InputfieldSomething > ___getConfigInputfields() > $f = $inputfields->get('pattern'); if($f) $f->attr('disabled', 'disabled'); To alter the pattern without reinstalling the Fieldtype, it isn't stored in the database? I can do it via API, but where is it stored? It's missing from the data column of the fields table for the field where all the other attributes are.
  9. DEVELOPMENT mode had to be enforced. But changing from DETECT to DEVELOPMENT and also checking "Restrict superusers" results in its disappearance again... Those options seem somewhat redundant, but the latter is to exclude any other roles granted the "tracy-debugger" permission from its use, however it doesn't seem to work. I tried with the permission created and unassigned, assigned, and deleted. Am I misunderstanding it? I reverted to DETECT and checked "Force superusers into DEVELOPMENT mode".
  10. It's not working in repeater field? Does besides. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_menu_pg.sort' in 'order clause' 49 secs Error saving field "Internal Page(s)" — SQLSTATE[42S22]: Column not found: 1054 Unknown... 49 secs That's Page Auto Complete applied, or Page List Select Multiple. Selections don't save in repeater fields with or without this applied.
  11. Sorry, 2, and don't remember, but I got it working on one by disabling all other modules.
  12. I tried messing with some settings to enforce it and changing the admin theme (but it doesn't show in frontend either). Doesn't appear to be in the page source.
  13. I tried $homepage->get('misc_site_meta')->where('title=year')->first() but first() isn't applicable and without it nothing. Trying to get value of subfield value_text; tried ->value_text in place of but that didn't work either. It's $homepage->misc_site_meta->first('title=year')->value_text
  14. Or it's working I guess but just not for one image with jpg extension weird the webp is in the files folder for the page with it
  15. $wire->addHookAfter('Pageimage::url', function(HookEvent $event) { static $n = 0; $image = $event->object; if(++$n === 1 && in_array($image->ext, [ 'jpeg', 'jpg', 'png' ])) { $event->return = $image->webp()->url(); } $n--; }); [https://processwire.com/blog/posts/webp-images-on-an-existing-site/] This works great unless shown by $page->images->getRandom(); ?
  16. I was thinking to utilize URL segments for pages via external API, however I don't know how those would be indexed by search engines reliably/conveniently? I'm guessing a script could be written to ask for them to be crawled? but I'm not sure whether that's worth it. Does anyone here do this? for fairly complex articles of data? I think I've seen on here before people mentioning synchronizing real estate databases, for example, to native PW and/or vice-versa... That would be the way to go, then? to enable PW-independence? Otherwise maybe have a module for managing the external database (like crud) within the PW admin and integrating the API, where for each external record, a page exists (is created/deleted/unpublished accordingly) with its name = id in db. With just the corresponding ID to the record, probably views and SEO at least could be dynamically generated... Any drawbacks or concerns that come to mind
  17. Thanks. I had known about that module and was going to maybe modify it to suit the use case but quit the project.
  18. Is there a built-in way to handle incoming email?
  19. This is compatible with PW 3. Is there any reason you would not use it in production? I tried hCaptcha but that's more laborous for users.
×
×
  • Create New...