Jump to content

Harmen

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by Harmen

  1. @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.
  2. 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?
  3. @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
  4. 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?
  5. 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
  6. PW: 3.0.39 Should probably update this soon ProField Table: 0.1.4
  7. Thanks, that did the job. It's not clear though, also could not find anything about it
  8. 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?
  9. 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. That's okay. It's weird but I can't figure it out either
  11. 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?
  12. 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
  13. 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?
  14. 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
  15. I managed to solve this issue. If you have questions about how I did that, do not hesitate to PM me
  16. Hi All, 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. $feature_groups = json_decode($product->features, true); if (is_array($feature_groups) || is_object($feature_groups)) { foreach ($feature_groups as $feature_group_id => $feature_group) { $groupPage = wire('pages')->get($feature_group_id); if ($groupPage) { $row = $page->features_repeater->getNewItem(); $row->feature_group_selector = $groupPage; foreach ($feature_group['features'] as $feature_id => $feature) { $featurePage = wire("pages")->get($feature_id); if ($featurePage) { $valuePage = wire('pages')->get(key($feature["values"])); if ($valuePage) { $feature_row = $row->feature_repeater->getNewItem(); $feature_row->feature_attribute_selector = $featurePage; $feature_row->feature_value_selector = $valuePage; } else { continue; } } else { continue; } } $row->save(); } else { continue; } } } Then the user can change / add features, click save and done! Now the issue is that I can't detect any changes made to the repeater field! So when the user clicks the save button I execute the following code: private function processUpdateFeatures(InputfieldForm $form){ $form->processInput($this->input->post); if (count($form->getErrors())) return false; $feature_items = $form->get('features_repeater')->value; foreach ($feature_items as $feature_item){ $group = $feature_item->feature_group_selector; if ($group["id"] != 0){ $groupPage = wire('pages')->get($group["id"]); $this->message($groupPage->title); $features = $feature_item->feature_repeater; foreach ($features as $feature){ $attribute = $feature->feature_attribute_selector; $value = $feature->feature_value_selector; $attributePage = wire('pages')->get($attribute["id"]); $valuePage = wire('pages')->get($value["id"]); $this->message($attributePage->title); $this->message($valuePage->title); } } } } But the only thing that the messages show me is the old values and not the new values. What am I doing wrong here or am I missing a step? Anything that points me in the right direction is greatly appreciated! ~Harmen
  17. Yeah I finally found the culprit. This is a multi-lingual website with up to 9 languages. I guess the module created the pages with only one language enabled to be viewed and I had to click the checkbox for the other pages manually. I should've seen this earlier ? Thanks for the great and fast support though.
  18. Yep, that works. You can visit the blog page here: website
  19. So i've created 3 more posts with some sample content: The $blog->renderPosts("limit=$limit") function still returns that it can't find any posts. If I add include=all to the line to find the post, then I can find all the posts. IDK what is going on here
  20. Nothing. But the page is published, so it should be listed right? Yeah I use $content all the time. I just wanted to list the posts so I could apply my own CSS after the code for the listing is done. So my blog.php file looks like this now: <?php namespace ProcessWire; // CALL THE MODULE - MarkupBlog $blog = $modules->get("MarkupBlog"); // === Get the limit $settings = $pages->get('template=blog-settings'); $limit = $settings->blog_quantity; // === Initialize $content $content = ''; // Render limited number of posts on Blog Home Page $content .= $blog->renderPosts("limit=$limit"); // => Returns "No posts found" // === Code for testing purposes to see the difference //$posts = $pages->find('template=blog-post,limit=5, include=all'); => Returns 1 $posts = $pages->find('template=blog-post,limit=5'); // => Returns 0 $content .= $posts->count; $options = array( "Breadcrumbs" => true, ); // === Function to render the whole page, including some options and markup $content = renderPage($page, $content, $options);
  21. The echo returns '1', which is correct. There is one post published. The TracyDebugger dumps returns a big array which I think is correct too: ProcessWire\PageArray #71aa selectors protected => ProcessWire\Selectors #0607 finderOptions protected => array () lazyLoad protected => FALSE keyIndex protected => array (1) 11903 => 0 numTotal protected => 1 numLimit protected => 5 numStart protected => 0 data protected => array (1) 0 => ProcessWire\Page #9d06 extraData protected => array () itemsRemoved protected => array () itemsAdded protected => array () duplicateChecking protected => TRUE useFuel protected => TRUE _instanceNum private => 1718 localHooks protected => array () trackChanges private => 2 changes private => array () _notices protected => array (3) errors => NULL warnings => NULL messages => NULL _wire protected => ProcessWire\ProcessWire #1005 debug protected => FALSE fuel protected => ProcessWire\Fuel #4473 data protected => array (29) [ ... ] lock protected => array (21) [ ... ] requiredInterfaces protected => array (1) [ ... ] pathSave protected => "" instanceID protected => 0 shutdown protected => ProcessWire\WireShutdown #090d useFuel protected => TRUE _instanceNum private => 3 localHooks protected => array () trackChanges private => 0 changes private => array () _notices protected => array (3) errors => NULL warnings => NULL messages => NULL _wire protected => ProcessWire\ProcessWire #1005 { RECURSION } EDIT: I do get an error by TracyDebugger though when I click on the 'Blog' tab in the backend: Illegal offset type on line 916 in ProcessBlog.module $posts->title => array('published' => $qn['blog-post'], 'unpublished' => $qn['unpublished'] ), I can skip the error while everything keeps working. I don't know if that has anything to do with it. Just wanted to let you know.
  22. I have TracyDebugger up and running. Doesn't throw any errors. Yes, I can output other pages. The page containing the post has normal right, like every other page. Just like the parent of the post and the blog page itself. Result of some tests I did. There is no specific reason, was just trying some things because I don't know why it isn't working
  23. Hello, This module is great! However I have some issues with outputting the posts on the blog template. I've published a blog post and tried to output the post on the blog page with the following code: $blog = wire('modules')->get("MarkupBlog"); // main content $content = ''; //$content .= "<h2>{$page->get('blog_headline|title')}</h2>"; //render a limited number of summarised posts $content .= $blog->renderPosts("limit=5", true); This code is provided with the module so I suppose it works. However it just returns that there are no posts found. I also tried to find the posts by myself, not using the module with the following line of code: $posts = wire('pages')->find("template=blog-post, sort=-blog_date"); But if I try to output the page ID or the title, it returns nothing. I double checked the post that the page is published (it is published and not hidden) so in theory I have to find the page but no matter what I do, I can't find the posts. What am I doing wrong here or can someone point me in the right direction?
  24. First of all, this module is great! Unfortunately I'm having some issues. Yesterday most of the SEO data was filled in for the website. We're running a multi-lingual website, so I've changed the fieldtypes and everything worked as expected except for the homepage. For example: when I am searching the company name on google (NL), the website shows up with the link to the dutch homepage which is alright, but the seo description hasn't changed while the field isn't empty in the SEO tab on the Homepage. I can see that the meta data is in the page but google doesn't use it. Is this a known issue and can it be solved or is it something different? Thanks in advance!
  25. Hello all, Was wondering if any of you tried to include the Exact PHP client by Picqer in Processwire (URL)? I am trying to at the moment but I am stuck at the Authorization process. Building it inside a module file to execute a certain function every 6 hours to update something on the website. For the authorization process the file has to execute the following piece of code: header('Location:'. $urlThatRedirectsMeToTheLoginOfExact); But each time I am trying to do so, I get the following error: Cannot modify header information - headers already sent by (output started at /processwire/index.php:55). I am out of options so that's why I am trying to find someone who used this library and could get it to work or someone who knows how I can fix it. Tips are highly appreciated (if they work ;)) Cheers, Harmen
×
×
  • Create New...