Jump to content

Mr. NiceGuy

Members
  • Content Count

    30
  • Joined

  • Last visited

Community Reputation

6 Neutral

About Mr. NiceGuy

  • Rank
    Jr. Member

Recent Profile Visitors

1,772 profile views
  1. 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); });
  2. 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?
  3. @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.
  4. 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.
  5. 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.
  6. 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);
  7. 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.
  8. 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:
  9. 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.
  10. 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; } } }?>
  11. 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?
  12. 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?
  13. 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!
  14. As the last answer is nearly a month old now. How is the status on this?
  15. 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.
×
×
  • Create New...