-
Posts
127 -
Joined
-
Last visited
Harmen's Achievements
Sr. Member (5/6)
58
Reputation
-
Harmen started following Can't add pages to Page field [Asmselect] , Access module from another domain via API? and Module: CKEditor
-
@dragan Thank you so much for trying all these options. Using a template I can get the same results as you. Running this in the module file for some reason it keeps listing the pages of the domain the module is installed on instead of the domain I am trying to access. I really hope this gets easier in the future. For now I think I am going to create a dummy template for every domain that takes some variables and returns the file I need. Again thanks so much for looking into this. Let's hope this will be an option in the near future.
-
This is what I tried at first but then I get the following error, it just doesn't seem to work. Any code after that doesn't execute because of this line. Any ideas?
-
@dragan Yes, still it isn't working, if I include the other domain from the current directory the module is installed in, I get the following error for this piece of code: require "../../../processwire_NL/wire/core/ProcessWire.php"; $site = new \ProcessWire\ProcessWire('../../../processwire_NL/site/', "https://www.domain.nl"); // ERROR: Compile Error: Cannot declare class ProcessWire\ProcessWire, because the name is already in use (line 0 of /var/www/vhosts/r-go-tools.com/httpdocs/processwire_EN/site/assets/cache/FileCompiler/var/www/vhosts/r-go-tools.com/httpdocs/processwire_NL/wire/core/ProcessWire.php) If I include the other domain from the root directory I get the following error with this piece of code: require "./var/www/httpdocs/processwire_NL/wire/core/ProcessWire.php"; $site = new \ProcessWire\ProcessWire('./var/www/httpdocs/processwire_NL/site/', "https://www.domain.nl"); // ERROR: Warning: require(/var/www/vhosts/r-go-tools.com/httpdocs/processwire_EN/site/modules/ExportProductData/var/www/httpdocs/processwire_NL/wire/core/ProcessWire.php): failed to open stream: No such file or directory in /var/www/vhosts/r-go-tools.com/httpdocs/processwire_EN/site/assets/cache/FileCompiler/site/modules/ExportProductData/ExportProductData.module on line 446 Now this is the first time I am trying to achieve something with bootstrapping PW so please forgive any mistakes
-
Could work if it was accessible, path to domain y is not withing the allowed paths from domain x according to the errow below: Doesn't seem like the safest option... Scratch that, used the wrong path. Seems like you can't bootstrap Processwire in an existing PW installation because of class declarations: Or am I doing something wrong?
-
Hello, Currently I have a domain setup for 4 languages, each language has its own domain. Databases are seperated. Per domain I have a module that is able to export the data of all products on the website in an excel file. Now this only exports the single language of the domain the module is installed on, so far so good. Now my sales colleagues want one portal to download the data file from domain x while they are logged in at domain y instead of logging in to every domain to get the file they want, which is only logical. The module is ready and the necessary functions are accessible from the front-end of the website. So one way would be to create a page on each domain that takes the necessary variables, loads the module on its domain and download the file to the user. However, I was wondering if it is possible to access via the API the module on domain y from domain x? Thanks in advance, Harmen
-
PW: 3.0.39 Should probably update this soon ProField Table: 0.1.4
-
Thanks, that did the job. It's not clear though, also could not find anything about it
-
Whenever I try to modify the Multilanguage textarea fields to a multilanguage CKEditor field or create a new multilanguage CKEditor field in a Table field, I cannot use the field because it gives me the following error: Settings are all set (see image above) and I don't know where to look else. Also, when I modified the original field (which goes flawless for other field somewhere else) I lost all the data that was in there. How can I fix this and use the field?
-
Doesn't work, $selectedProduct isn't a Page object but a string. -- The reference field is just a Text field. $selectedProduct is a string. The reference field holds the reference of the product which is unique for each product. Used TracyDebugger, and this are the results: This returns a string, the exact same string that the product has stored in the reference field. This returns a Page Object, containing the actual page that I want to add to the AsmSelect Page field. Conclusion: $productPage contains an actual page that exists, but for some reason I cannot add this page to the AsmSelect Page Field. Did some more digging and found the following: There are 7 categories: each containing a different kind of products. I have no problem with adding the products of the first 4 categories, but for the remaining 3 categories it doesn't work, a hardcode string for these pages doesn't help either, even though I can find the pages manually in the selector.
- 10 replies
-
- inputfield
- asmselect
-
(and 2 more)
Tagged with:
-
That's okay. It's weird but I can't figure it out either
- 10 replies
-
- inputfield
- asmselect
-
(and 2 more)
Tagged with:
-
Yes, checked everything a couple times. Don't know why I can't set the values Yes No, they are published and not hidden Yes Can it be a problem that the page with this field has a template without a file?
- 10 replies
-
- inputfield
- asmselect
-
(and 2 more)
Tagged with:
-
Tried that but doesn't work. Doesn't fix the problem either. I have no problems editing the other fields in the repeater, it's just the AsmSelect Page field
- 10 replies
-
- inputfield
- asmselect
-
(and 2 more)
Tagged with:
-
I want to add a few pages to an AsmSelect Page field inside a repeater using the following code: $trialsPage = wire("pages")->get(28422); // Get the page $trialsPage->of(false); $newTrial = $ordersPage->trial_repeater_orders->getNewItem(); // Add item to repeater foreach ($selectedProducts as $selectedProduct){ $productPage = $pages->get("template=product, reference=$selectedProduct"); $newTrial->trial_selected_products->add($productPage); } $newTrial->save(); $trialsPage->save(); However, when I check the page where the field is located it doesn't have the new values as expected. The selected pages exist, the field is in the right location, made sure that the output formatting is turned off: $page->of(false); But it still doesn't work with a variable. No matter what I try, it doesn't work. It only works when I replace $selectedProduct with a hardcoded string. Am I doing something wrong here?
- 10 replies
-
- inputfield
- asmselect
-
(and 2 more)
Tagged with:
-
Hi All, I've made a previous regarding an issue which I solved but I stumbled across a new issue :). Below again the explanation needed. You need a short introduction for this. The company I am working for has approx. 80 products on their website and they all have their own features. The features are imported from an older system which isn't used anymore. Back then, when they changed from the old system to PW, we imported the features into the product pages as a JSON-array so the pages could load a bit faster as exploding a JSON array is a bit faster than loading in a lot of items from a table or a repeater field. How the JSON array looks like: { "2": { // The ID of the group that contains the actual features "name": "Model and function", // The name of the group "features": { "43": { // Attribute ID "name": "Resolution (DPI)", // Attribute name "values": { "896": "500-1500-2000-3500" // Value ID and value name } } } } } Now we are adding a few more products to the catalog with new features and some that are already in use by other products but I am really struggling to assign the right ID's with the correct values in 7 different languages without messing up filters etc. So I decided to develop a module that lets you easily add feature groups, attributes and values as pages and connect these to the product using a repeater. This started by exporting all the current groups, attributes and values and import them as pages in the following structure: - Features - Feature Groups - Group 1 - Group 2 - ... - Feature Attributes - Attribute 1 - Attribute 2 - ... - Feature Values - Value 1 - Value 2 - ... Secondly, I created a repeater field that I assigned to the 'Features'-page that can handle the JSON structure explained above by seeing each item of the repeater field as a group. Inside each item you can select the group page and you will find another repeater which contains 2 page selectors to select an attribute and a value. A single repeater field looks like this: Next step was to create a module that gets this field as an Inputfield from the Features page. Once the user has finished adding groups, attributes and values he can click on save and I export all the values in the same JSON array structure as earlier but now the ID's of the groups, attributes and values are just the page ID's. This works great to add new features to new products. BUT, sometimes the features of a product change or need to be changed and you don't want to change the JSON array manually. So my idea was to do the same thing as adding the features, but now you grab the values from the product first and populate the items of the repeater field. $featuresPage = wire("pages")->get("template=features"); $featureGroups = json_decode($product->features, true); foreach ($featureGroups as $featureGroupID => $featureGroup){ $row = $featuresPage->features_repeater->getNewItem(); $groupPage = wire("pages")->get($featureGroupID); $row->feature_group_selector = $groupPage; $row->save(); foreach ($featureGroup["features"] as $featureID => $feature){ $featuresRow = $row->feature_repeater->getNewItem(); $attributePage = wire("pages")->get($featureID); $valuePage = wire("pages")->get(key($feature['values'])); $featuresRow->feature_attribute_selector = $attributePage; $featuresRow->feature_value_selector = $valuePage; $featuresRow->save(); } $row->save(); } $featuresPage->save(); $f = wire('fields')->get('features_repeater'); $inputfield = $f->getInputfield($featuresPage); $form->add($inputfield); $f = $this->modules->get("InputfieldSubmit"); $f->name = 'updateFeatures'; $f->label = 'Update Features'; $f->icon = 'plus'; $f->value = 'Update Features'; $form->add($f); Then the user can change / add features, click save and done! It is possible to update the feature attributes and values, but when I change the feature group value, it seems like PW creates a new field behind the scenes and keeps the old value as well. So let's say I have the following feature structure: - Feature Group 1 - Feature attribute 1 - Feature value 1 Now I want to update Feature Group 1 to Feature Group 2, below is the desired result and the actual result: // === Desired result - Feature Group 2 - Feature attribute 1 - Feature value 1 // === Actual result - Feature Group 2 - Feature attribute 1 - Feature value 1 - Feature Group 1 - Feature attribute 1 - Feature value 1 I am using the following function to update the features: private function processForm5_UpdateFeatures(InputfieldForm $form){ $form->processInput($this->input->post); if (count($form->getErrors())) return false; $pageID = $this->session->selectedProduct; $product = wire('pages')->get($pageID); $product->of(false); $repeater = $form->get("features_repeater")->value; $languages = wire("languages"); foreach ($languages as $language) { $return_array = []; $i = 0; foreach ($repeater as $repeaterItem) { //$this->message($repeaterItem); $group = $repeaterItem->feature_group_selector; if ($group["id"] == 0) { continue; } else { $group = wire("pages")->get($group["id"]); $feature_group_name = &$return_array[$group->id]['name']; if (!isset($feature_group_name)) $feature_group_name = $group->title->getLanguageValue($language); $features = $repeaterItem->feature_repeater; foreach ($features as $feature) { $this->message($feature); $attribute = $feature->feature_attribute_selector; $value = $feature->feature_value_selector; if ($attribute["id"] == 0 || $value["id"] == 0) { continue; } else { $attribute = wire("pages")->get($attribute["id"]); $value = wire("pages")->get($value["id"]); $return_array[$group->id]['features'][$attribute->id]['name'] = $attribute->title->getLanguageValue($language); $return_array[$group->id]['features'][$attribute->id]['values'][$value->id] = $value->title->getLanguageValue($language); } } } } $product->features->setLanguageValue($language->name, json_encode($return_array, JSON_UNESCAPED_UNICODE)); } $product->save(); $featuresPage = wire("pages")->get("template=features"); $featuresPage->features_repeater->removeAll(); $featuresPage->save(); /* $this->messages("clear all"); $this->errors("clear all");*/ $this->message("Updated all features for {$product->title}"); $this->session->redirect("../"); } Is there a way to avoid the current result and get the desired result? Why is there even a new repeater page created for the new value? Anything that can help me is greatly appreciated! ~Harmen
-
[Solved] Editing a repeater field, but values aren't updated
Harmen replied to Harmen's topic in Module/Plugin Development
I managed to solve this issue. If you have questions about how I did that, do not hesitate to PM me