Jump to content

Robin S

Members
  • Posts

    4,791
  • Joined

  • Days Won

    303

Everything posted by Robin S

  1. The hook needs to be in /site/init.php, not /site/ready.php
  2. Another option: $Events = $pages->get('/Events/')->Events_repeat->slice(-3);
  3. Looks very clean and sleek. I'm a little concerned the default UIkit styling of some components takes the minimalist aesthetic a bit too far. There's a point where the visual metaphor breaks down and usability suffers. Take the 'tabs' component... In the first screenshot it is much more obvious: that it will respond as a tabbed interface as opposed to some other type of navigation which tab is active which parts of the page are contained within the area the tab navigation controls (e.g. you can see that the "Save" button is outside the tabbed area). Edit: I realise that UIkit will only provide the foundation styling for the admin and will be customised for use there. So this is more just an observation about the decisions made by the UIkit designers rather than something that will be a problem for the finished PW admin theme.
  4. Simplest way is to put your jQuery into a function and call it on DOM ready and also on ajaxComplete: $(function() { myPageTableFunction(); }); $(document).ajaxComplete(function() { myPageTableFunction(); }); But you could use a hook rather than the jQuery approach: $this->addHookAfter('Fieldtype::markupValue', function($event) { $field = $event->arguments('field'); $page = $event->arguments('page'); if($field->name == 'my_text_field' && $page->template->name == 'my_pagetable_template') { $text = $event->return; if($text == 'aktiv') $event->return = "<span class='uk-badge active'>$text</span>"; if($text == 'abgesagt') $event->return = "<span class='uk-badge cancelled'>$text</span>"; } });
  5. The parent of the PageTable pages must use a template that the editor has "add children" permission for.
  6. The solution to both of these is to create a parent for your PageTable pages under the Admin branch of the tree. Edit: actually, that doesn't deal with the second question, but this thread has some techniques for disallowing direct access to a page:
  7. Those links are for Profields Table, which is a different thing than PageTable. PageTable is an installable module in the core but there's no formal documentation for it. Repeater Matrix has a friendlier UI in that you can see all your content in Page Edit without having to open modals for each 'block'.
  8. I thought of another option around this: you could give the 'module-admin' permission to the role, and then use a hook to check which module is being requested and only allow access to a particular module. $this->addHookBefore('ProcessModule::executeEdit', function($event) { if(!$this->user->isSuperuser() && $this->input->get->name !== 'MarkupSEO') { throw new WirePermissionException('You do not have permission to configure this module.'); } }); Now you just need to create a custom link in admin to the module config page, maybe using a simple Process module. Or I think AdminOnSteroids lets you add custom menu items - haven't tried it myself.
  9. That looks cool. Is only Nginx available or is Apache an option?
  10. If you want your hook to fire on the saving of all pages but the one you are updating in your hook you would do: public function UpdateAnotherPage($event) { $page = $event->arguments('page'); if($page->id !== 1240) { // update page 1240 } }
  11. You misunderstand what I'm saying: you are hooking page save, but saving a page inside your hook - that recurs indefinitely.
  12. You are missing the crucial step in your hook where you check what page was saved and then decide if you want your page update code to run. You don't want that update to occur on any page save like it does now, because then it will trigger again when the updated page is saved in the hook, and so on until the cows come home.
  13. It's possible, but I don't think there is a way to limit the access to a single module. Module configuration uses the ProcessModule process. If you check the source for that class you can see the permission that is needed to get access to the process: 'module-admin'. So you can create that permission and give it to a role, but then they can configure any installed module, which would be quite dangerous. Also, the modules menu still doesn't appear for the role - you'd have to dig around in the admin theme modules to find out what prevents that menu item from rendering. An alternative would be to create a custom Process module that provides the same config fields and then save to the MarkupSEO config on page save. Then you can give access to that one Process module.
  14. What is actually happening when you upload larger files? PHP error message? Any JS errors in the browser console? Do you have debug mode on and Tracy Debugger installed and activated for the back-end?
  15. This jQuery plugin seems to do the job without any obvious performance issues: http://laertejjunior.github.io/freezeheader/
  16. Re-reading the docs, I'm not sure why Ryan advises against using option B with Repeaters or PageTables (for Files/Images fields it makes sense). Maybe he means if you are wanting to make the entire Repeater/PageTable field editable rather than the individual fields inside the items, because it does seem to work fine for the latter case (once the access bug is worked around).
  17. Why is it a lot of extra effort? There's not that many field classes, and you would know which are in use in your installation and just check for those, for each returning the data that suits that class.
  18. Strings and arrays are different types of data, and a PageArray is a actually an object but you can think of it as a special kind of array. Long story short, you can't use PageArray methods on a string. It's difficult to help without seeing the code where you set the $pageArray variable.
  19. Welcome @VirtuallyCreative! substr() is the function that is usually used to get a portion of a string in PHP. substr($page->title, 0, 2)
  20. Looks like internally $sanitizer->date() is relying on strtotime() to check that the date is valid, and this function for some reason returns a timestamp for '2017/02/31' rather than 'false'. It should perhaps be changed to checkdate() which correctly identifies that date as invalid. In the meantime you could add an extra validation: function validate_date($value) { $parsed = date_parse($value); return checkdate($parsed['month'], $parsed['day'], $parsed['year']); }
  21. I think you can do this with core PW fields, and enhance it with some custom JS if you want. Here's what I'm thinking... You have your Place pages in their own branch of the tree. The Place template has a repeater field "Offers" where all the possible offers for that Place are defined. Then you have a repeater field "Places" on your Partner template. You add two Page Reference fields to the repeater: 1. "Place", which is a single select field limited to the Place template. 2. "Choose offers" which is a multiple AsmSelect field using a "Custom PHP code" hook. The hook will return the value of the "Offers" repeater field (which will be a PageArray) for the place that is selected in the "Place" field. Now this hook is a bit trickier than normal because your Page Reference fields are inside a repeater and so you don't want $page to be the page being edited, but rather the repeater page that contains your fields. So in the hook you need to get the inputfield name and extract the ID integer portion of it and use that to get the $page object. I can explain more about this if you decide to go down this road. So this approach should work but it will require editors to save the page after choosing a place in the "Place" select, before they can choose offers for that place. If you wanted to enhance it a bit more you could have the "Choose offers" field allow all offers pages (limit using the Offers repeater template rather than a custom PHP hook) and then use some custom JS in admin to empty the inputfield options on load and on change of the "Place" select it gets the offers for that place via AJAX and populates the "Choose offers" options.
  22. Issue has been opened on GitHub: https://github.com/processwire/processwire-issues/issues/183
  23. It is only option D that forces the modal dialog editor. Option C allows inline editing - you just have to place edit tags around the individual fields in your repeater rather than around the whole repeater foreach(). For example: <?php foreach($page->my_repeater as $item): ?> <h3><edit <?= $item->id ?>.title><?= $item->title ?></edit></h3> <?php endforeach; ?> You're right that there does seem to be some sort of permissions issue for non-superusers, but rather than change access for the admin template (which non-superusers shouldn't have access to) I suggest you give edit access to your repeater template (select the "Show system templates" option to see repeater templates).
  24. Did you check the front-end editing documentation when investigating your problem? It specifically advises against using option B for Repeaters:
  25. @Juergen, you can create inputfield dependencies based on any arbitrary PHP/API code using the Custom Inputfield Dependencies module, but these are only evaluated when Page Edit is loaded/saved so it may not suit your needs.
×
×
  • Create New...