Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    161

Everything posted by kongondo

  1. Wow! Almost a year gone and no answer!
  2. Link to the module?
  3. Anything in a Process Module tagged executeXXX is a page (not a physical one though, but a URLSegment). So, if you have executeTesta, and visit /log-in/module-name/testa/, if there is nothing being returned there (a string output), you will see the error, Process Returned No Content. Not really. There is no correct location. You can have the form in execute() but handle the Ajax request in executeTesta() or wherever you wish. These virtual pages (executeXXX()) offer a lot of power and versatility. All you need to tell the Ajax call in jQuery is where url is. So, you can do url:/log-in/module-name/testa/ and you will be able to handle the Ajax request in executeTesta() :-). You can even have executeTesta() do nothing but handle Ajax requests (maybe rename it to executeAjax(). If the page is accessed directly (i.e. non-ajax request), you can have it redirect to execute(), otherwise (if Ajax sent), process it. In a nutshell, you make the decision about what works for you. ProcessWire doesn't really mind
  4. Do you need to actually update the sub-domains in the sense that you want to save to their databases OR Do you need them to reflect some changes made to the central site? (i.e. changes made and saved in central site database) If #2, the you can pull the changes made in the central website and display them in the sub-domains using ProcessWire's multi-instance feature Actually, if #1, you can also use multi-instance but that will need a bit more work since you will have to be saving to sub-domains as well. What sort of updates will these be? Text? What about the fields, complex (like Repeaters) or Text inputs? You will also need to decide on what triggers the 'fetching' or 'pushing' of new data from/to the sub-domains. Cron? Web views? You could also use REST API for this. In a hurry, hope above make sense.
  5. I meant what you see in Chrome (or Firefox) Dev console (not Tracy, although Tracy can show you responses [not just calls] to Ajax calls). Add the following code to the place (in your module) you are expecting to receive the Ajax request. Then, open the Chrome console ( still viewing your page with the form), head over to the Network menu item and onto the XHR tab then execute your Ajax call. if ($this->wire('config')->ajax) { echo "Ajax post received"; exit; } In the XHR tab, inspect the response of the Ajax request sent to /log-in/moduleName/. Do you see the message "Ajax post received" as the response? I suspect you will not, because I think, you have your ajax response code in executeTesta() which is a different page within your Process Module. Its URL is /log-in/moduleName/testa/. I think that is what is happening. You are posting to the main page of your Process Module but checking for the ajax response in another page (Testa)...or the other way round
  6. I haven't thoroughly tested this (nor fully read the post you linked to) but it works. Edit/Note: code be will be updated in line with the changes in OP. See new post below In /site/ready.php $pages->addHookAfter('save', function($event) { // get the page object saved $page = $event->argumentsByName('page'); // only on pages with a temporary parent (old template) if($page->template !='old-template') { $this->message('page has wrong template'); return; } // if page still unpublished return if($page->is(Page::statusUnpublished)) { $this->message('page still unpublished'); return; } // good to go; assign new parent and template $page->parent = '/new-parent/'; $page->template = 'new-template'; $page->save(); $this->message('page template and parent changed'); }); Messages in there are for testing. Edit as needed
  7. On which page do you have the form being submitted? Do you have it in /your-module-page/testa-page/ ? I'm not sure what the implications of url: "" (empty string) are. To post to self you can do url: "./" If you echo something inside the check for $config->ajax, e.g. echo 'I got that' and check that in the (chrome) console xhr panel, would do you see? I'm not sure if return $input will work. I.e., I don't know how long the $input->post variables will be alive for.
  8. Listen to ajax calls like this: $sanitizer = $this->wire('sanitizer'); if ($this->wire('config')->ajax) { // ajax sent, process inputs $input = $this->wire('input')->post; $someID = (int) $input->someID; $showOptions = (int) $input->show_options; $name = $sanitizer->name($input->name); $someTextArray = $sanitizer->array($input->someTextArray, 'text'); // blah blah $data = array('message' => 'error'); if(1 == $someVar) $data['message'] = 'success'; echo json_encode($data); exit;// or the halt() thingy... } // no ajax else { }
  9. Hi. 2 - 3 weeks at least. Media Manager is really keeping me busy, I am afraid.
  10. Old topic below but might provide some insights
  11. Welcome to the forums @Mikael, Here's a simple explanation of Dos and Don'ts (regarding MPL 2.0): https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2) So, yes, you can modify it as you wish. As the summary at the above link, you have to: Include Copyright Include License Disclose Source Etc
  12. Not out of the box, I don't think so. A user is a page like any other page. They share the same parent, Users (ID 29). You cannot have more than one page with the same name under the same parent in ProcessWire.
  13. Three options to get the discussion going Bootstrap either ProcessWire or your eCommerce App. The one being bootstrapped stores the user data REST API: The eCommerce App can request and receive user data using REST or similar (@see ProcessWireGraphQL) Invest in the native ProcessWire eCommerce app, Padloper .
  14. This worked for me. See the changes in getLanguageValue(); The echo's were too much for me ; I substituted them for $out (code be made even cleaner, but this is a start). function createArticle($el){ $out = ''; //$el->setOutputFormatting(false); $title = $el->getLanguageValue('default', 'title'); $titleFR = ($el->getLanguageValue('fr', 'title') ? $el->getLanguageValue('fr', 'title') : $title); $titleNL = ($el->getLanguageValue('nl', 'title') ? $el->getLanguageValue('nl', 'title') : $title); $out .= ' <div class="close closeArticle"><span>×</span></div>'; //$out .= ($el->title ? '<h2>'. $el->title .'</h2>' : ''); $out .= ($el->title ? '<h2>'. $titleFR .'</h2>' : '');// @note: just for testing $out .= ($el->sous_titre ? '<h3>'. $el->sous_titre .'</h3>' : ''); $out .= '<div class="dates">'; $out .= ($el->date_debut ? '<h4 class="dateDebut"><span></span> ' . $el->date_debut . ' </h4>' : ''); $out .= ($el->date_fin ? '<h4 class="dateFin"> <span> ⤑ </span> ' . $el->date_fin . '</h4><br>' : ''); $out .= ($el->vernissage ? '<h4 class="vernissage"> <span>vernissage : </span>' . $el->vernissage . '</h4>' : ''); $out .= '</div>'; $out .= ($el->images ? '<img src="' . $el->images->first()->url . '" alt="" />' : '' ); $out .= '<div class="content">'; $out .= ($el->contenu ? $el->contenu : '' ); $out .= '</div>'; $out .= ($el->en_savoir_plus ? '<p class="savoirPlus">' : '' ); $out .= ($el->en_savoir_plus ? '<a href="' . $el->en_savoir_plus . '" target="_blank">En savoir plus</a>' : '' ); $out .= ($el->en_savoir_plus ? '</p>' : '' ); return $out; } I have not looked at the rest of your code in detail...
  15. @bernhard, @dragan's is different (e.g. it has image search in there) from the one I use which I think has been around a lot longer .
  16. Excellent! I don't think you need $u->of(false) for a new record/page, btw. Btw2, I testing saving a field in an existing $mainsite->somePage and it worked OK. However, I noticed two things: I expected PW to throw an error if I attempted to save the page without turning output formatting off, but it didn't Reloading the page where I was viewing content from $mainSite->somePages, the changes made to the above field were only visible after a 2nd reload Did you experience this @modifiedcontent?
  17. Similar(-ish) issue?
  18. Yeah, I can confirm this. From my testing ,$mainsite does not seem to have access to $session. Security? I don't know, just guessing.
  19. Forgot to show where $forum is defined in your example code? Would be good to show the complete, correct code to help others, thanks.
  20. Hmm, why? Do you have an upcoming project? Although we are in 'Off Topic', I don't get the point of starting a new thread instead of 'continuing' the discussion (if there is one), using the existing threads:
  21. Yeah. I've had it in my signature for ages (so, you see, we are not so clever ) . I can't remember who created this particular CSE though. I also have it bookmarked in my bookmarks bar for easy access.
  22. Hi @hezmann That's because the code (in the field) is locally scoped so that $page refers to the page you are editing. However, if using wireRenderFile(), you need to get the page being edited yourself. When editing a page, the page (named) edit is what ProcessWire assigns to $page. The page edit has the id 10. So, what you need is code like below to get the page being edited: $currentPage = ''; $process = wire('process'); if($process && $process->className() == 'ProcessPageEdit') $currentPage = $process->getPage(); if(!$currentPage) return; // if you get here $currentPage is the page being edited More in this post. Sorry, this should be in the docs. I will update the docs at some point (when I get the time). Hope this helps.
  23. No worries . Btw search tip: Use this one instead: E.g., searching for restore trash page or restore trash page api returns $pages->restore() as the second result and your question as the fifth .
  24. // Grab a page from the trash and restore it $trashedPage = $pages->get(1234); $pages->restore($trashedPage); http://processwire.com/api/ref/pages/restore/
  25. @andrew24, Moderator Note Please consider this your first and final warning against spamming in these forums. This forum is for ProcessWire jobs. You had hidden a link to your non-ProcessWire CMS behind your email address. I have removed your email and the said link.
×
×
  • Create New...