Jump to content

Mr. NiceGuy

Members
  • Posts

    35
  • Joined

  • Last visited

Recent Profile Visitors

2,009 profile views

Mr. NiceGuy's Achievements

Jr. Member

Jr. Member (3/6)

8

Reputation

  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; } } }?>
×
×
  • Create New...