Jump to content

Hani

Members
  • Posts

    110
  • Joined

  • Last visited

Everything posted by Hani

  1. Ah - got it! Thanks for the explanation, Ryan. The behavior makes sense now.
  2. Thanks guys. I solved it by using $page->image->removeAll() which works just fine. I'm not convinced that the behavior should be the way it is (even if it is intended). If I upload an image in the admin, it hides the existing image using javascript immediately, but upon saving the page, the existing image is replaced with the new one. I would think that the same behavior would apply to the API. As mentioned before, if I upload multiple images with the API and go to edit the page, I'll see multiple photos in that field. Essentially, this is an array of photos. The maximum file settings description says: Maybe I'm on the wrong side of the fence here? This isn't a huge issue and is easily solved by manually deleting the image using the API, but I figured it is worth discussing. Edit: I do have to say that the current behavior can prevent accidental, and irreversible, deleting of assets. So perhaps it is worth leaving it as is for that sole reason?
  3. I think I found a tiny bug when using the API and interacting with an image field. I have an image field with the maximum number of files set to 1 in its configuration. When you upload an image directly in the admin panel, it behaves properly and removes the existing image - replacing it with the new one. However, whenever I add an image using the API, (example code below) it doesn't remove the existing image; it keeps both, ignoring the maximum number of files setting. $page->image->add('http://www.domain.com/image.jpg'); Not a huge deal, but possibly something to put on the "to do" list. I suppose I should ask if someone can confirm the bug and that it's not just me. EDIT: This isn't a bug. The behavior is expected. Read Ryan's post for the reasoning & logic behind the behavior.
  4. Hani

    PGP Encryption

    Does anyone have any experience with PGP / GnuPG encryption? I'm having some trouble with the decryption part of it and was wondering if anyone might have some insight. Thanks!
  5. I got this figured out. It was a problem on my end. I have a "city" page field in the User template that used an AsmSelect input. The problem was that I recently imported over 30,000 cities into the database. As a result, trying to edit the user required the input field in the edit form to be populated with every city. Duh! I changed the input type to PageListSelect and it solved the problem.
  6. Every time I try to edit a user, I get a timeout error: Fatal error: Maximum execution time of 100 seconds exceeded in /home/snip/public_html/wire/core/Array.php on line 83 Anyone have an idea why? I just noticed the issue, but it may have been like this for a while. The most recent change was that we cleaned out empty folders using this module: http://processwire.c...iteassetsfiles/
  7. My pleasure! Thanks for this module, Wanze. I love it!
  8. I figured it out! I noticed the AJAX queries to grab the data are including the API Developer key in the URL. However, according to Google (https://developers.g...rence#q_summary) it says that the parameter is optional and that you should do that when authenticating with OAuth 1.0. Since the module uses OAuth 2.0 for authentication, that query parameter should be left out. I commented out this line in the module (line 930 under the _loadGoogleApi function): $this->ga_client->setDeveloperKey($this->developerKey); That seems to have done the trick! It's loading the data beautifully! (And it also allows me to select the domain in the drop down correctly too.)
  9. Oh! Okay - I didn't know that you're supposed to leave the Profile ID blank and allow the module to set it for you once you select a domain from the drop down. So, I revoked access, deleted the cached folders and re-authenticated. When I expected to see the drop down, I now see this error: Error calling GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties?key=AIzaSyCrlnK06s5YWsui7VWnH62GFYjBqjAGpZw: (403) Access Not Configured
  10. By the way - I figured out a straightforward way to get your Google Analytics Profile ID. Go to your Google Analytics Account and select the domain you're working with. Click on Admin near the top right Click on the Profile tab The number is located next to "Profile ID" Like Soma mentioned, this is different for each domain you have in Google Analytics.
  11. Oops! Totally missed that. Thanks. But, like Soma, after I put that number in like Wanze instructed I'm getting the "403 access not configured" error. I've never seen the drop down. Wanze, thanks for all your efforts on this module! I'll play around to see if I can figure out the solution.
  12. I'm getting a strange error when I go to the GA page (after authenticating) that shows up for each section were data is supposed to show up. The end of the errors say: Values must match the following regular expression: 'ga:[0-9]+'"} It is referencing the Google Analytics Account ID that I provided, which is in the format of UA-XXXXXXXX-X. That's the right GA Account ID to provide, correct? The installation instructions say to "Choose a Google Analytics Account from the Dropdown". However, I didn't see any place to do that. Is that related to the problem I'm having?
  13. Digging up an old thread, but I wanted to post some more info since the problem still exists. Just like you both confirmed on your own, if I define my decimal places to be rounded out to 6 spots on a float field, it still saves with 4. I'm saving latitude and longitude values, but I need to be able to use greater-than and less-than comparisons in selectors. Looking at the database via phpMyAdmin, I noticed that the float fieldtype is still being created as a FLOAT column and not DOUBLE. I also noticed that the Length/Values for the column definition of the FLOAT field wasn't defined. I manually set it to "10,6" (no quotes) and kept it as a FLOAT. It did the trick and the values saved correctly. HOWEVER - Ryan mentioned the limitation of 6 decimal spots for the FLOAT column type. I did some research it a little and found this info on the MySQL website: Source: http://dev.mysql.com...oint-types.htmlSince that's the case, I decided that changing the field type to DOUBLE as apeisa suggested was a better solution and allows for a little more flexibility. Is changing the default column type created for Float fieldtypes from FLOAT to DOUBLE going to be integrated in a future PW release?
  14. You're welcome! Most thanks goes to you, Ryan, since I based this off your Modules Select plugin.
  15. I needed a field that would allow me to select one or more templates, very much like the Page Select. So I created a module that does just that! I based it off of Ryan's FieldtypeModules because the functionality is quite similar. You can also define which templates are selectable by the asmselect field. Hope this helps someone that wants to do the same thing! FieldtypeTemplates.module
  16. Glad you got it to work, Evan! I've been bogged down with deadlines recently - but it's still on my radar to make this into a module. I'll definitely post it once it's done.
  17. Thanks for the feedback, Ryan. Great idea. Now, by copying it to a separate module, does it automatically override the core functionality? Meaning, should I keep InputfieldPage.module as it was before I tweaked it or should the core file keep the changes as well? Edit: Nevermind! I should have tried before I even asked. Turns out it doesn't override the core functionality - which makes sense. I haven't come across forum posts or documentation that indicate how to override core modules. Is it safe to assume that you can't without replacing the core modules themselves, correct? (If so, I would guess this would be done so that the risk of other modules breaking due to dependencies is minimized.)
  18. I finally had a chance to take a stab at this - and I'm pleased with what I was able to do. I added the functionality directly in the core - in InputfieldPage.module as Ryan said I would have to do. I decided to leave the Label Field intact and simply add a couple more configurable fields. It makes sense to simply replace the Label Field (InputSelect) with the Multiple Label Field (AsmInputSelect) I added, but didn't want to remove the core functionality in case I missed some trickle-down implications. (Ryan, would there be any?) What this does is add two configuration fields to the Page fieldtype. The first allows you to define multiple fields to use as the label for selectable pages. It simply gives you a combination of the selected values imploded with " - ". The second field I added (a text field) allows for ultimate flexibility; you can define the pattern to use for the label, so you can do things like: {title}, {parent->title} Anyway, here's what I did in the InputfieldPage.module: After line 28 in the $defaultConfig array, add the following: 'labelFieldNames' => '', 'labelFieldNameCustom' => '', Replace line 114 in the getInputfield() function with the following: if ($this->labelFieldNameCustom) { $label = preg_replace('/{(.*?)}/ie','$child->$1', $this->labelFieldNameCustom); } else if ($this->labelFieldNames) { $labelItems = array(); foreach ($this->labelFieldNames as $f) { $labelItems[] = $child->get($f); } $label = implode(' - ', $labelItems); } else { $label = $this->labelFieldName ? $child->get($this->labelFieldName) : $child->name; } After line 367 in the ___getConfigInputfields() function, add the following: // MULTIPLE FIELD LABELS $field = $this->modules->get('InputfieldAsmSelect'); $field->setAttribute('name', 'labelFieldNames'); $field->setAttribute('value', $this->labelFieldNames); $field->label = 'Label Field (Multiple Page Fields)'; $field->description = "Select the page fields that you want to be used in generating the labels for each selectable page. This setting supercedes the single field label option."; $field->collapsed = Inputfield::collapsedBlank; if ($this->fuel('fields')->get('title')) { $field->addOption('title', 'title (default)'); $field->addOption('name', 'name'); $titleIsDefault = true; } else { $field->addOption('name', 'name (default)'); $titleIsDefault = false; } $field->addOption('path', 'path'); foreach ($this->fuel('fields') as $f) { if (!$f->type instanceof FieldtypeText) continue; if ($f->type instanceof FieldtypeTextarea) continue; if ($titleIsDefault && $f->name == 'title') continue; $field->addOption($f->name); } $inputfields->append($field); // CUSTOM FIELD LABELS $field = $this->modules->get('InputfieldText'); $field->attr('name', 'labelFieldNameCustom'); $field->attr('value', $this->labelFieldNameCustom); $field->label = "Label Field (Custom)"; $field->description = "Define the page fields (enclosed in braces) that you want to be used in generating the labels for each selectable page. This setting supercedes the multiple field label option."; $field->notes = 'Example: {title}, {parent->title}'; $field->collapsed = Inputfield::collapsedBlank; $inputfields->append($field); It's working beautifully for me! Ryan - does it look like I missed anything? I saw that labelFieldName was referenced in the ___renderAddable() function, but I wasn't sure what that does.
  19. Got it. Thanks, Ryan! This isn't a major priority for me right now - so I'll tackle this later. I'll post what I come up with.
  20. I'd love some direction on how best to tackle this issue. Under a Page field's configuration, you're able to "select the page field that you want to be used in generating the labels for each selectable page." With that configuration, you're able to select only one field. I'd love to be able to use multiple page fields' values to generate the label. For instance, my Page field allows me to select any of the users in PW. I'd love the labels to be a combination of their first name, last name, and email address - which are all separate fields. What's the best way to approach this? Should I be looking at creating a new inputfield? If so, which module do I extend? InputfieldPage? Thanks for any guidance! EDIT: Solution for ProcessWire 2.3.0 is out on GitHub: https://github.com/Hani79/Processwire_FieldtypePageWithLabels
  21. Setting PW to advanced mode (which I actually didn't even realize was there!) didn't do it - but importing the fields from the admin template did the trick. Thanks, guys!
  22. How do I go about adding the process field to a new template? I created a new template and placed it under the admin page (I also set it to use the admin template) - however, I don't see the "process" field as an option to be added to it. Thanks in advance for any pointers! Edit: To clarify, I assigned "admin" as the alternative template filename for this new template because I need to add other fields to it.
  23. Ah ha! Thanks guys! This is fantastic and really helps me to make better modules with better integration. Thanks, again.
  24. I'd like to add some functions to $user. For example I'd like to be able to do the following: $user->sendThankYou(); I tried creating the following module: class UserExtended extends User implements Module{ public static function getModuleInfo() { return array( 'title' => 'Extended User Module', 'version' => 100, 'summary' => 'Extends Processwire\'s Core User Module', 'singular' => true, 'autoload' => true ); } public function sendThankYou() { // Do something } } But I get the following error: Class UserExtended contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Module::init) (line 18 of /home/hani/public_html/site/modules/UserExtended.module) At that point, I thought, "Of course. "User" isn't a really a module. It's not in the Modules list. It extends Page." I'd really appreciate any direction on how to do this.
  25. Yup - $featuredTag returned just fine. It was a mistake in my code in a loop below it. Silly me.
×
×
  • Create New...