Jump to content

kongondo

PW-Moderators
  • Content Count

    6,040
  • Joined

  • Last visited

  • Days Won

    99

kongondo last won the day on December 10 2019

kongondo had the most liked content!

Community Reputation

6,760 Excellent

About kongondo

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling
  • Location
    UK

Recent Profile Visitors

27,996 profile views
  1. Maybe not what you need, but could be worth looking at the new module Dashboard?
  2. Hi @e0f, Currently, this is not doable out of the box. However, using the method getMenuItems() (see a few posts up for examples), you can use the property pagesID (or index pages_id if getting back array of menu items) to get ($pages->get($m->pageID), for example) the respective ProcessWire pages of the menu items and return the custom fields you want, e.g. description. Having said that, I would not recommend this. It seems like an overkill and may not be very performant based on the number of menu items and other factors. Perhaps if you could explain your use case, I would see if I can add an option to retrieve the values of simple fields (text, integers, dates, etc) for use with getMenuItems(). MenuBuilder is primarily for building navigation menus. From your example, it seems you are using it for a different purpose? Maybe provide a fuller example so that I can get my head around this.
  3. Anything that repeats in any programming language calls for, invariably, something you can iterate/traverse (e.g. an array) and the tool you use for the traversal/looping, (e.g. foreach). Let's go with these two. Looking at the UIkit markup you've pasted, I suppose some of the classes are automatically injected by UIkit JavaScript. However, the basic structure of the markup that repeats is the same. Hence, I'll ignore markup classes for now. The main differences in the images ratio markup are the following: The main containers for the images vary in the class they have. The first, the second and the fourth have the class: <div class="uk-width-expand@s">...</div> The 3rd image container has a different class: <div class="uk-width-2-3@s">...</div> Secondly, the <img> markup themselves have different values for their data-height attribute. Hence, we will need some variable to store these differences. Although some of the values are shared, for instance, the class for the main images container for the 1st, 2nd and 4th images (as stated above), I prefer to store each image's values separately. This can help down the line if the markup changes resulting in different values that were previously identical. Although it may be simple to assume that the images in your image field (which I will refer to as images) are already arranged in order and are in the correct size, from experience, we know that this will most likely NOT be the case. Clients can upload images that are not of the correct size and arrange them randomly. You may need to cater for this, e.g. have the clients tag the images with first, second, etc....but that may be too much work. OK, for the fun part. Please note that in the examples below, I only focus on the images' container part. I have also left in the CSS just for reference, although they may be auto-injected as stated above. We have at least two ways to loop through our images. Both ways involve having an array that will have 4 nested arrays, one each for our 4 images. The first way to loop through our images is to loop through the images themselves and access the array with images info inside this loop as shown below: The main downside to the above approach is we are assuming there will always be four images in the images field. What if a client adds more? What if there are less images? All these will require adding checks in the code (within the loop) to check how many images we have. To counter some of these challenges, we can instead loop through the array with the info for images as shown below: This is just basic code to get you started. There are a number of things that could be improved. For instance, you may want ProcessWire to resize the images for you (done once) rather than depending on your browser to contain larger images. See the Resize and crop section in the API documentation here. There are alternative approaches as well to the examples shown above. PS: code untested
  4. HTML specs say select tag does not have readonly attribute. Use disabled instead. I think a disabled select will not POST though.
  5. @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.
  6. 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?
  7. @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 😆
  8. 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! 😂👍
  9. 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; }
  10. 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; }
  11. 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...
  12. 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).
  13. 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.
  14. 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.
×
×
  • Create New...