Search the Community
Showing results for tags 'FieldTypeMulti'.
-
I'm developing a multi value fieldtype and there's this method called getLoadQueryAutojoin(). // FieldtypeMulti.php /** * Return the query used for Autojoining this field (if different from getLoadQuery) or NULL if autojoin not allowed. * * @param Field $field * @param DatabaseQuerySelect $query * @return DatabaseQuerySelect|NULL * */ public function getLoadQueryAutojoin(Field $field, DatabaseQuerySelect $query) { if($this->get('useOrderByCols')) { // autojoin is not used if sorting or pagination is active $orderByCols = $field->get('orderByCols'); if(count($orderByCols) > 0) return null; } $table = $this->database->escapeTable($field->table); $schema = $this->trimDatabaseSchema($this->getDatabaseSchema($field)); $fieldName = $this->database->escapeCol($field->name); $separator = self::multiValueSeparator; foreach($schema as $key => $unused) { $query->select("GROUP_CONCAT($table.$key SEPARATOR '$separator') AS `{$fieldName}__$key`"); // QA } return $query; } Why would someone need to autojoin a field, or not need a autojoin? Any benefits/drawbacks? I havent used the feature it at all in my 3+ years PW experience. I'm not sure whether I need to implement it but I am leaning towards returning null and disable it altogether.
-
As part of the webmention module I am working on, I want to detect if the page being viewed has the "Webmentions" field and if so, add a Link: header. I have hooked before PageRender::renderPage to add the header and that works OK. I am having trouble checking for the Webmentions Fieldtype, though. FieldtypeWebmentions extends FieldtypeMulti and is empty on new pages. My code below does not work because the $field->type is returning NULL when the Webmentions field is empty. When the Webmentions field is not null, then it returns the Fieldtype as expected. How can I reliably check if a page's template has a specific Fieldtype, whether the field is empty or not? Am I missing something in the Fieldtype or Inputfield classes for the module? Thanks for any help! private function findFieldtypeWebmentions(Page $page) { # loop: each field for this page foreach ( $page->fields as $field ) { if ( $field->type instanceof FieldtypeWebmentions ) { $this->webmention_field = $field; return TRUE; } } # end loop return FALSE; } # end method findFieldtypeWebmentions()