Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    160

Everything posted by kongondo

  1. @gebeer, Not sure if you know that a similar module shares the same class name as yours (FieldtypeImagePicker). I don't know if @theo's module is still being maintained. It also does not seem to be in the module's directory. It may not be an issue but just good to know, just in case.
  2. Why does this have to be Multi Select? Shouldn't it be either checked or not (i.e a single select?) Aah, I see, it seems you have different status? Correct. If that's the case, it is better to use Pages:saved. However, please further explain your scenario, i.e. If a page is already set to booked, but it is edited, should an email be resent? What is booked? Is it the name of a page? What if a booking is cancelled, is an email to be sent?
  3. Check out Pages::added hook
  4. @gebeer You might want to clean-up some of the copy-paste inline comments that shipped with the example code from your module's code ?
  5. Great! Btw.. You don't need to set inbuilt ProcessWire columns like 'pages_id in your getDatabaseSchema() :-). ProcessWire will do it automatically. Same with extra, unless you really are adding something extra. Thanks for confirming! ??
  6. Oops. I was looking at the wrong file, so not sure if you are currently doing this? If not, here are examples: public function ___wakeupValue(Page $page, Field $field, $value) { // some code... // start a blank value to be populated $myClassWireArray = $this->getBlankValue($page, $field); // if we were given a blank value, then we've got nothing to do: just return a blank MyClassWireArray if(empty($value) || !is_array($value)) return $myClassWireArray; // create new myClassObj objects from each item in the array foreach($value as $v) { $myClassObj = new MyClass(); // @note we're converting 'data' to 'property1' (this is the filename) $myClassObj->property1 = $v['data']; $myClassObj->property2 = $v['column_2']; $myClassObj->property3 = $v['column_3']; $myClassObj->setTrackChanges(true); $myClassWireArray->add($myClassObj); } $myClassWireArray->resetTrackChanges(); return $myClassWireArray; } public function ___sleepValue(Page $page, Field $field, $value) { $sleepValue = array(); // some code.... // convert each MyClassObj to an array within sleepValue foreach($value as $myClassObj) { $sleepValue[] = array( 'data' => $myClassObj->property1, // @note: property1 is becoming data (this is the filename) 'column_2' => (int) $myClassObj->property2, 'column_3' => (int) $myClassObj->property3 ); } return $sleepValue; }
  7. You might also need something like this in your getMatchQuery() // if normal sql characters, do 'normal' query, else do fulltext search if($this->wire('database')->isOperator($operator)) { return parent::getMatchQuery($query, $table, $subfield, $operator, $value); } else { $ft = new DatabaseQuerySelectFulltext($query); $ft->match($table, $subfield, $operator, $value); return $query; }
  8. Try ___getSelectorInfo(). Grep wire folder for full examples. Here's some example code. @see the label index in the code. <?php /** * Get information used for InputfieldSelector interactive selector builder * * This is for Lister purposes. * We want nice labels for our lister selects (i.e. not raw db ones, i.e. 'some_column'). * * @param Field $field The field we are working with. * @param array $data Array of extra data, when/if needed. * @return array * */ public function ___getSelectorInfo(Field $field, array $data = array()) { $info = parent::___getSelectorInfo($field, $data); ## filterable subfields for this field ## // we get rid of the subfield 'data' instead, we'll use 'custom one' => IF APPLICABLE TO YOU! if(isset($info['subfields']['data'])) unset($info['subfields']['data']); // unset misc_data (example column we don't need in filter) if(isset($info['subfields']['misc_data'])) unset($info['subfields']['misc_data']); $subfields = array( // @note: @see getMatchQuery! // text column example 'some_text_column' => array( 'name' => 'some_text_column', 'input' => 'text', 'label' => $this->_('My Text Column'),// NICE LABEL FOR LISTER // @note: comment out those that don't make sense! 'operators' => array('%=', '!%=', '*=', '!*=', '~=', '!~=', '^=', '!^=', '$=', '!$=', '=', '!=', '=""', '!=""'), 'options' => array(), ), // number column example 'some_number_column' => array( 'name' => 'some_number_column', 'input' => 'number', 'label' => $this->_('My Number Column'), // @note: commented out those that don't make sense 'operators' => array('=', '!=', /*'<', '>', '<=', '>=',*/ '=""', '!=""'), 'options' => array(), ), ); $info['subfields'] = array_merge($info['subfields'], $subfields); return $info; } If it doesn't work, I'll need to dig a litter deeper...
  9. Yes it should (but test ?). Just remember that in your getDatabaseSchema() for data, you will need to set correct column type (text or varchar, etc) and the correct index type (fulltext most likely if using text).
  10. Yes it is, unless something changed that I am not aware of. In __sleepValue() and __wakeupValue() convert it from/to your property and in getMatchQuery() make sure to pass the correct $subfield (as you are currently doing in both respects). What are you currently using data for? pageid? Please show us an example search.
  11. Yeah. You can do a lot of fancy stuff in wakeupValue(). You can even create run time values and add them as properties in your $field object, or even fetch data elsewhere and add these as runtime properties, etc.
  12. Thanks for the clarification. I don't know how SettingsFactory works. However, I doubt it accesses your field's database schema. I would imagine it will only be interested in the data you return in ___wakeupValue(). In addition, I don't know how SettingsFactory fetches the data, i.e. automatically or via an API called by the developer. Is it not possible for devs to convert what is returned in FIP to JSON/text for use in SettingsFactory? Alternatively, if you wish to return JSON values, you can do that in ___wakeupValue() but store your respective data sets (pageid and filename) in separate columns without the need for that extra column. It's not a deal breaker in FIP but you really want to avoid data redundancy in your database. Maybe if I understood better how SettingsFactory works I'd be able to give a better-informed response.
  13. This is already integrated. Each country (most countries!) has its own locale data (currency symbol, tax rate, provincial/territorial taxes if applicable, tax names, decimal symbol, etc). Tax rates can be overridden per country (and per territory if applicable). This is a frontend issue which you will need to integrate yourself using ProcessWire $language API and your method of detecting customers location (taking into account the various pros and cons of each). This is about shipping zones. It is already built in but you will have to set up the zones yourself including: The shipping countries (and territories if applicable) Shipping rates in that zone, whether they are flat- or price- or quantity- or weight-based Whether you are using shipping classes (e.g. light goods, fragile products, hazardous, bulky, etc) As well as shipping methods (e.g. normal, express, next day, Post Office, etc). Specifying a maximum shipping fee (if you wish) as well as shipping handling fee (optional) Etc The above allow a lot of control straight out of the box. This is about a 3rd-party software. You will have to do the integration yourself using Padloper 2 API (for inventory). Probably not practical in your case, but please note that in Padloper 2 you can manually create an order (or using the API).
  14. @gebeer What exactly are you storing in this JSON column? I've just had a quick look and it seems you only store pageid and the filename (which you also store separately in the their respective columns). Am I missing something?
  15. Update: Menu Builder 0.2.6 Changelog Added the properties numChildren, totalChildren and showMoreText for use with getMenuItems(). Added option maximum_children_per_parent to limit the maximum number of (included) children a menu item can return. Thanks @derelektrischemoench for inspiration/request. Fixed CSS issue that affected menu items' trash cans in the backend. Thanks @duncan. Refactored code to improve efficiency. In dev branch only for testing. I have also updated the docs, especially around getMenuItems(). @derelektrischemoench, See this gist for an example recursive menu builder function that uses maximum_children_per_parent and showMore. OK, breaktime over, back to Padloper! :-).
  16. Hi @derelektrischemoench. I'll post an update later today. Thanks.
  17. Ah I see. I mistakenly thought you wanted to do a comparison. Yes, it does work. I was just wondering if it is a new PHP 7 feature or a PHP quirk. I am just used to count(array) or empty(array) Btw, did you see my edit above? The filter works fine for me with FieldtypePage check.
  18. Not an answer to your question. Is this a typo here or your actual code? // assignment operator and not comparison operator if ($productTemplate = $this->wire('templates')->get(MarkupSnipWire::snipcartProductTemplate)) {} In addition, isn't this meant to be a non-empty array check? Did PHP 7 change this type of check? if ($allowedFieldTypes) Edit Tested and filtering works fine for me with 'FieldtypePage'
  19. Glad you got it sorted.
  20. Hi @brdje. First, welcome to the forums! I am glad you are finding the blog module useful. You are right. A massive oversight on my part! I will work on this as soon as I get a bit of time, which might not be soon, I am afraid. Since posts are just pages, you could just use PW API directly to access each blog field and let PW deal with the fetching of the value in the current language. For instance (rough example): $posts = $pages->find("template=blog-post,limit=20"); $out = ""; foreach($posts as $post) { $out .= "<h2>{$post->title}</h2>"; $out .= $post->blog_body; $thumb = $post->blog_images->first()->width(250); $out .= "<img src='{$thumb->url}'>"; $out .= '<hr>'; } echo $out; It's not ideal, but it should get you started, meanwhile.
  21. Oops, sorry, totally slipped my mind! I'll have a look ?.
  22. Aah. I see what is happening. It isn't strange, actually, but working as expected. When output formatting is off, the value of an image or file field is always a WireArray irrespective of the field's maximum files allowed or the setting in formatted value. There is a note on the field. Please see the screenshot on this post. The reason you didn't need first() in the frontend is because output formatting is on there. In the backend, where your rtm external file is called, output formatting is off, hence the need for first(). You can test this by using TracyDebugger to dump the results of the image field in both your external rtm file and in the template file used in the frontend. You should see the backend dump returning Pageimages and the frontend one Pageimage as illustrated below. bd(get_class($page->image)); Backend dump Frontend dump
  23. Hard to tell without seeing some code. Maybe you image field is set to contain multiple images. In that case $image->url may not work. Could we see some code please. Please note that it is advisable to use the option Render PHP file(s) instead.
×
×
  • Create New...