Jump to content

Mr. NiceGuy

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by Mr. NiceGuy

  1. Okay I fixed it by changing it to this and removing the square bracket: ingredientWrapper.ingredientList.ingredient=1031 Seems inconsistent to me that it does work with one notation and not the other one depending on the user.
  2. I have this weird problem where results of pages->find are different depending on the user I am logged into even though I use check_access=0 or include=all The field I am looking into as a repeater named ingredientWrapper that has a nested repeater called ingredientList which contains a page reference element named ingredient. This returns the correct result as superuser and no results as guest. ( I know that include=all and check_access are superflous) echo $pages->find('template=recipe, include=all, check_access=0, ingredientWrapper=[ingredientList.ingredient=1031]'); This returns all the results including the ones that I want to filter out as guest and superuser. echo $pages->find('template=recipe'); I tried a simple subselector and that works fine also for the guest (e.g image.alt=test) Any pointers?
  3. Very nice module. It actually also works without a paid account using the free api. The only thing one needs to do is to change one line as the api endpoint is different. 500000 characters for free per month which should probably be enough for many applications. classes/DeepL.class.php: $reqUrl = "https://api-free.deepl.com/v2{$endpoint}?auth_key={$this->apiKey}"; I got a javascript error with the module though if I use a non-CK Editor text field (CK editor not found). The textarea field is in a repeater and I saw you fixed a bug related to this in the last release. Presumably the issues are related. I am on the latest PW dev 3.0.179 Uncaught ReferenceError: CKEDITOR is not defined at HTMLAnchorElement.<anonymous> (fluency.js:257)
  4. That was it! Thanks! Probably xxx.template would match the id of the template but I didn't check that.
  5. I have added a page reference field to my users and there all contributions that user has made are listed. (they are programatically added via the api). I am wondering why the first of these queries works (returns the two pages with ids 1083,1130), whereas the second one does not return anything. The pages both have template 'mytemplate'. Is template not supported as a subfield? $uList = $this->pages->find('template=user, roles=login-register, contributions.id=1083|1130, contributions.count>0, limit=10,sort=-created, check_access=0'); $uList = $this->pages->find('template=user, roles=login-register, contributions.template=mytemplate, contributions.count>0, limit=10,sort=-created, check_access=0');
  6. Thanks bernhard! For reference i did this: $(document).ready(function() { function poll() { $.get("./ #all_sub", function(data) { $("#all_sub").replaceWith(data); pwPanels.init(); }); } setTimeout(poll, 15000); });
  7. I am developing a custom Backendmodule where submissions can be managed. I am using MarkupAdminDataTable to display the pages with Edit button, then upon click a custom page opens in a panel and then the parent of the page is modified. The page should then disappear from the table, so I wanted to reload the table with ajax. $out = "<div id='all_sub'>"; $table = $this->modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->id = 'submissionstable'; $table->headerRow(array( $this->_('Name'), $this->_('Mail'), $this->_('Title'), $this->_('Submission date'), $this->_('Actions'))); $drafts = $this->pages->find('template=talk|poster,parent="/contributions/saved/",limit=10,sort=-created'); foreach($drafts as $draft) { $button = $this->modules->get('InputfieldButton'); $button->value = 'Approve'; $button->attr('data-href', './edit/?id='.$draft->id); $button->addClass('pw-panel'); $table->row(array( $draft->speaker->name => "edit/?id={$draft->id}", $draft->speaker->email, $draft->title, date($this->config->dateFormat,$draft->created), $button->render() )); } $out .= $table->render(); $pager = $drafts->getTotal() > count($drafts) ? $drafts->renderPager() : ''; $out .= $pager; } $out .="</div>"; When I implement a function like the one described in @bernhard great tutorial on custom backend pages however the panels don't open anymore. Precisely they stop opening after the first poll. I couldn't find any state specific variables on the markuptable. Did I miss one ? $out .='<script> $(document).ready(function() { function poll() { $.get("./ #all_sub", function(data) { $("#all_sub").replaceWith(data); }); } setTimeout(poll, 10000); }); </script>'; What is the best way to update my markuptable after the panel is closed?
  8. @alexmercenary, Maybe the fix here will help you: https://github.com/danielstieber/SubscribeToMailchimp/issues/9 I am also having troubles using this module. The test for the api settings works but when i try to subscribe a user it does not work. I dumped the response text and I get "{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Resource Not Found","status":404,"detail":"The reques ... I am on localhost at the moment but I guess that should not matter? Anybody had this problem so far? EDIT: Problem fixed with 0.0.6 dev branch on github.
  9. Hi, I am working on a site where people can enter iframes which will be saved and displayed to other users. I want to prevent XSS but at the same time I want that any site can be embedded as iframe. I want to prevent something like <iframe src="javascript:alert(0)"></iframe> but it should still be possible to use any src url for the iframe. I know that one can use the sanitizer with htmlpurifier options to only allow safe origins (say youtube, vimeo). echo $sanitizer->purify($str, $options = ["HTML.SafeIframe" =>true, "URI.SafeIframeRegexp" =>'%^https://(www.youtube.com/embed/|player.vimeo.com/video/)%'] ); Is there are smart way to have a minimal level of protection whilst allowing any url for the iframe? Expanding the RegEx in the options obviously works but is this already enough? echo $sanitizer->purify($str, $options = ["HTML.SafeIframe" =>true, "URI.SafeIframeRegexp" =>'%^https://%'] ); Would love to hear some other opinions.
  10. The pages itself were not in the admin branch. Eventually I realized that they were visible in the default language but not in the language I was viewing. Inlcude=all did indeed solve the problem.
  11. I used this code on my site as well and added uppy meta information for setting the page id where the files will be uploaded. Here is the code if you are also looking how to do this: <script src="https://transloadit.edgly.net/releases/uppy/v1.9.2/uppy.min.js"></script> <script> const uppy = Uppy.Core({debug: true, autoProceed: false, meta: { pageid: 1488 } }) .use(Uppy.Dashboard, {target: '#uppy-box', inline: true}) .use(Uppy.Tus, {endpoint: 'MYURL/uppy/', limit:10}); </script> $td = $files->tempDir('uppy'); // CMS $td_path = (string) $td; // Create TusPhp server $server = new \TusPhp\Tus\Server(); // Set path to endpoint - no trailing slash here $server->setApiPath('/uppy'); // Set upload directory $server->setUploadDir($td_path); // Listener function for when an upload is completed $server->event()->addListener('tus-server.upload.complete', function(\TusPhp\Events\TusEvent $event) { $file_path = $event->getFile()->getFilePath(); p = wire('pages')->get(intval($event->getFile()->details()['metadata']['pageid'])); // extract page id from uppy metadata $p->of(false); // CMS related $p->files->add($file_path); //CMS related $p->save('files'); //CMS related }); // Send response $response = $server->serve(); $response->send(); exit(0);
  12. I just had this same problem (some error in the translation csv I uploaded) and I fixed it through navigating to the admin page id folder in site/assets/files/LANGUAGEPAGEID/ and deleted all my templates*.json translation files.
  13. Did some more digging and turns out that $pages is available but it does not find the pages with the template that I am looking for. For example if I look for pages with template "basic-page" they are displayed in the PageTableExtended render, in the single page and in the frontend render. But if I look for the two specific templates in $pages-> that I want to display they are not shown. I checked the template name x times and also added include=hidden in the $selector and have no idea why they are not displayed. The name of the template is quite long but that should not matter, right? (16 chars). This is how it looks in PageTableExtended This is the front end:
  14. I'm having troubles using $pages->find and render(). I have a PageTable Field which holds pages that are saved under the admin. E.g $l has template "pagetableTMP" and is located under /admin/contentblocks/ if(count($page->content)>0){ foreach($page->content as $l){ $content .= $l->render(); } } In the frontend I render them like this where "content" is the PageTable field. In the template for $l there is this code: foreach ($pages->find('template=tmpname, sort=title') as $c) { echo " <tr class='hover:bg-gray-400'> <td class='py-4 px-6 border-b border-gray-300'>{$c->title}</td> .... </tr>"; } When I look at $l as a single page I get the correct output. However, when I look at the page with the $content field which should render $l I get no output at all because $pages is empty. The pages with template "tmpname" are not in the admin but are normal front-end pages.
  15. Thanks bitpoet. Must have overlooked the clone function. And yes you understood it correctly that I wanted to create those virtual instance only on rendering. In the end I however decided to create real pages kind of like MuchDev suggested via module by hooking into the save function of the single-event pages. The admin for the single-event template now looks like this: https://monosnap.com/file/t187kaF2xI7WxF79blA3D982uMT1ko The code for the module is as follows. Adapt it for your needs <?php class recurringEvents extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Recurring Events', 'summary' => 'Adds a function to create recurring events and add pages to Processwire when a checkbox is checked on page save', 'version' => 1, 'autoload' => true, ); } public function init() { $this->pages->addHookBefore('save', $this, 'hookSave'); } public function hookSave($event) { $page = $event->arguments[0]; # check if recurring is checked on the page beeing saved. if ($page->recurring==1) { $intervallString=$page->intervall->title; for ($i=1; $i <= $page->n_repeats; $i++) { // create new page $k= new Page(); $k->template = 'single-event'; // set template $k->parent = wire('pages')->get('/events/'); // set the parent $intervall='+'.$i.' '.$intervallString; // construct the $intervall selector for strtotimestamp +1 week or +1day, increase with iteration by 1 $k->setOutputFormatting(false); // Copy page fields from current page to newly created one $k->title=$page->title; $k->organisation=$page->organisation; $k->type=$page->type; $k->location->address=$page->location->address; $k->body=$page->body; $k->recurring=0; $k->dateStart= strtotime($intervall, $page->dateStart); $k->dateEnd = strtotime($intervall, $page->dateEnd); $k->save(); } $this->message("Sucessfully created ".($i-1)." copies of recurring event {$k->title}"); // on the current page set recurring to 0 again, no page->save() needed because the page will be saved after the hook automatically $page->recurring=0; } } }?>
  16. Thanks for the code examples gebeer, unfortunately they don't contribute to solving my problem. The +1week example is nice and elegant. Didn't know that one. You are right, my field intervall returns indeed a timestamp of a time point. The input field for the intervall asks the user to enter the next date when the event should occur. Then I calculate the time difference between the two events. I want to implement it like this because I think that this is the simplest solution to the probem. Probably not the most elegant one though Maybe I should have made that clearer. However your post doesn't solve my problem that I can't add multiple instances of the same page with different start/end dates to the same page array. Any ideas how can I achieve this?
  17. I use the following code to make instances of an event with the template single-event to make it recurring. Recurring events have the field recurring checked and in the intervall I let the user specify a time range (as timestamp) until the next event. What I now want is to display the original event and create 5 instances (each one intervall step further in the future). What I now have: $today=time(); $results = $pages->find("template=single-event,dateEnd>$today, recurring=0, limit=25"); $recurring = $pages->find("template=single-event,recurring=1, limit=25"); foreach ($recurring as $k) { for ($i=0; $i < 5; $i++) { $start=$k->dateStart+$i*($k->intervall-$k->dateStart); $end=$k->dateEnd+$i*($k->intervall-$k->dateEnd); $k->set("dateStart", $start); $k->set("dateEnd", $end); $results->add($k); } } $results->sort("dateStart"); What I get is only the second item i want to have (dateStart+intervall*1). How do I get the other ones with $i=0 and $i>1? I assume this doesn't work because the ids of the pages I add to the calendar are the same. Am I right?
  18. I'm building a knowledge base profile. What I'm currently on: A user with the role guesteditor gets logged in and is allowed to add a page with the parent "drafts". After the guesteditor saves his page I want to notify an admin who then moves the new page if any good to its destination. So far so good. My question now is if I can change the names and behaviour of the Publish and Save+Keep Unpublish Button to a Single "Request Permission from Admin" Button. After the button is clicked I would like to send an email to admin, save a value to the same page that the permission request was sent and display instead of the button a message like "permission requested on xx.xx.2015" How do I do this? I'm planning to write an autoload module like described here https://processwire.com/talk/topic/2331-doing-additional-logic-after-saving-a-new-page/ to populate some fields through the URL that the guesteditor clicks to add a new page. Are there similar methods to do the thing described above? Thanks!
  19. As the last answer is nearly a month old now. How is the status on this?
  20. Okay so a litte more detail to this. My Tree: Start -Itemroot ----Item 1 -------Item2 -Categoryroot ---Category ---subcategory I edit item1, which has the field pageselect assigend but unpopulated. (The Fieldtype is PageListSelectMutliple*+) . I then Create the page subcategory and publish it in a new tab. I close this tab and go back to my page Item1. The pageselect lets me select my newly created subcategory because it loads all available pages via ajax. When i hit save on item1 i get the forged request error. When reloading and saving afterwards it works. Im using 2.4 with default Theme. I tried two seperate installations on localhost and hosted server.
  21. Yep it works fine if you refresh page1, but if you dont refresh it will throw the forged request error. In my use case its pretty common to add new categories to the system while typing the main text. All progress during writing is lost if i just reload the page.
  22. How does PageFoldStatus work? Do i have to activate it somewhere. I installed it but my expanded page list does not stay when reloading the page.
  23. Hey Guys, two small Questions: First: I get reproducable errors for forged requests: The scenario is as follows: I edit a page. In another browsertab I insert another page into the page tree for example a category page. The first page i began to edit has a page selector "Category select". When I select the page i just created in the other tab and save my first page I get the "Forged request" error. Is this intended? On a quick forum research I found similar topics but they all seemed to deal with login problems. Second: Is there a way to allways have the page tree expanded ? I had a look in PageList.js but did not find a option to disable the auto-collapsed list.
  24. Superb, Works great! Thanks to everyone taking the time
  25. Hej Diogo, thanks for your efforts I tried your last code example and played with it. Seems to work fine with two and one level but I cant get higher levels to work? Have you tried 4-6 levels? . The iteration is going through all the 5 levels but your algorithm for the parents doesnt work out: All the pages of the respective level are included but two or three times depending on the level depth. 1049|1050|1056 --1049|1050|1056|1050|1051|1056 --1049|1050|1056|1050|1051|1056|1050|1051|1052|1053|1056 --1049|1050|1056|1050|1051|1056|1050|1051|1052|1053|1056|1012|1036|1050|1051|1052|1053|1054|1055|1056 Thats an example of the ouput for 4 levels. I tried some stuff but im rather a noob at php and have no idea what could be the problem //Modified code by me $allParents = $parents . '|' . wire('pages')->find("parent={$parents}"); // add new parents to existing echo $allParents ." --"; with Level depth of 5
×
×
  • Create New...