Jump to content

Robin S

Members
  • Content Count

    3,611
  • Joined

  • Last visited

  • Days Won

    207

Everything posted by Robin S

  1. Welcome @alanxptm! There are separate permissions that can be set on the Access tab of each template's settings: View Pages (normally all roles are given this permission), Edit Pages, Create Pages, Add Children. So besides the View Pages permission you would set the permissions as follows for the author role... category template: Add Children post template: Edit Pages, Create Pages
  2. Not sure why you would be seeing that. I tested here and couldn't reproduce - that kind of selector works fine for me regardless of limit.
  3. A couple of hooks that I have found useful in some situations... In the admin menus the icon associated with each page is normally determined by the "icon" item in the Process module config (e.g. as set in the getModuleInfo() method). But sometimes you might want to change that icon. For example, the Lister Pro module uses the "search-plus" icon, but this is not so good when you have multiple Lister Pro instances because it makes each instance less distinct. With the hook below I can use a custom icon for the extra Lister Pro instances I have added: // Add custom icons to Lister Pro menu items $wire->addHookAfter('Page::getUnknown(page_icon)', function(HookEvent $event) { $page = $event->object; if($page->process == 'ProcessPageListerPro') { if($page->title === 'Flora species') { $event->return = 'leaf'; } elseif($page->title === 'Flora images') { $event->return = 'picture-o'; } } }); If you change an icon in the admin menus like this you can do a Modules > Refresh to clear the menu cache and see the updated icon. And for Page List you probably know that you can assign an icon to all pages that use a template in the template's "Advanced" tab. But with the hook below you can assign icons to pages more dynamically based on any properties of the page. So, for example, you could assign a warning icon to a page to alert site editors if some important field was left empty. // Add warning icon to news items without a date $wire->addHookAfter('Page::getIcon', function(HookEvent $event) { $page = $event->object; if($page->template == 'news_item' && !$page->date_1) { $event->return = 'exclamation-triangle'; } });
  4. I think this is the crux of it - it's mostly a communication issue. It's not surprising that people come to PW with an experience of seeing how some other open-source GitHub-hosted projects are managed and expect that it's the same for PW. Many projects encourage the user base to submit pull requests. However, PW is not one of those projects and this probably needs to be communicated more clearly somewhere. Open-source is not one thing but many things depending on the project and those who manage it. My impression is that PW is open-source in the sense of "a very smart person made this software and you can use it for free and also modify it to suit your needs". But it's not open-source in the sense of "hey everybody, let's collaborate on writing code for this software". There will be pros and cons to the different approaches to managing an open-source project, but all things considered I think most would agree that the formula Ryan is following has proven very successful to date.
  5. @Ben Sayers, I created a pull request with a fix for this issue: https://github.com/Rayden/FieldtypeStarRating/pull/1 In the meantime you could update InputfieldStarRating.js with the code from here and do a hard refresh in your browser to clear the cache.
  6. Thanks, all working great. 🙂
  7. @Rob(AU), glad to hear you've got something working. Something to think about though: seeing as each portfolio page may have multiple tags, what happens if a user opens a portfolio page in a new tab via "tag=foo" and then the same portfolio page in a different tab via "tag=bar"? You only have a single session variable for the tagged pages so these will overwrite each other, and the portfolio page doesn't "know" which tag it is being viewed under. I think it would be better not to use session but to pass the relevant tag as a parameter in the URL. So you would write link URLs to portfolio pages under tag "foo" like "/path/to/page/?tag=foo" and under tag "bar" they would be "/path/to/page/?tag=bar". Then in your portfolio template you would have some code like this: // Initialise some null pages as fallback $prev_page = new NullPage(); $next_page = new NullPage(); // Get the tag from $input if any $tag = $input->get->text('tag'); // If there is a tag if($tag) { // Get the IDs of portfolio pages with this tag - assumes a tag field named "tag" // It's more efficient to just get the IDs rather than the full Page objects, especially if there are a lot of portfolio pages $tagged_ids = $pages->findIDs("template=portfolio, tag=$tag"); // Get the position (key) of this current page in the array $page_position = array_search($page->id, $tagged_ids); // Get the previous page if any if(isset($tagged_ids[$page_position - 1])) { $prev_page = $pages($tagged_ids[$page_position - 1]); } // Get the next page if any if(isset($tagged_ids[$page_position + 1])) { $next_page = $pages($tagged_ids[$page_position + 1]); } } And where you want to output the prev/next links: <?php if($prev_page->id): ?> <p><a href="<?= $prev_page->url ?>?tag=<?= $tag ?>">Prev page</a></p> <?php endif; ?> <?php if($next_page->id): ?> <p><a href="<?= $next_page->url ?>?tag=<?= $tag ?>">Next page</a></p> <?php endif; ?> This way each portfolio page knows the tag it is being viewed under, and it means you can do things like share a link to a portfolio page such that the tag is specified.
  8. There's no drawback that I know of but this module is pretty new so it's possible that something will reveal itself over time.
  9. That sounds like an issue that should perhaps be fixed in the core - when redirecting due to lack of access I don't think this should be permanent redirect because as you say the user may just need to log in and then they should have access. Maybe you can create a GitHub issue for this to get Ryan's take?
  10. The actual action I noticed this on works with an external database so it's not easily shareable but attached is a demo action that shows the issue. Thanks for taking a look at this. DemoAction.action.php
  11. Hi @adrian, Within an admin action we have the option to return true or false depending on if the action succeeded or failed (and I assume success or failure is up to the action author depending on what the overall objective of the action is). If an action returns true then a database restore link is shown. But it seems that if the action returns false then the link to restore the database is not shown. I'm not sure if no backup is made or it's just the restore link that's missing - maybe the former because when I manually visited the /restore/ URL segment and clicked the Restore button then the restore didn't work. Is it possible to get a backup and a link to restore it when an action returns false? Also, maybe the background colour of the failure message could be a pale red because it's hard to see links against the dark red (there's actually a link to the logs in the failure message above). BTW, the module readme doesn't make it entirely clear that an action should return false on the fail state, as only the failureMessage is mentioned:
  12. I think you might be working with the wrong init.php - you'll see in my earlier post that the hook needs to go in /site/init.php. Along with /site/ready.php this is one of the places that hook code is commonly added to. You can create either/both of these files if they don't exist. More info in this blog post: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks Turn off ProCache while you are investigating the issue to make sure it isn't contributing to the problem.
  13. @gerritvanaaken, I created a module in response to your topic:
  14. A module created in response to the topic here: Page List Select Multiple Quickly Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page. The screencast says it all: https://github.com/Toutouwai/PageListSelectMultipleQuickly https://modules.processwire.com/modules/page-list-select-multiple-quickly/
  15. @Ben Sayers, you can use bd() to dump the $url variable in the hook. $wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) { $url = $event->arguments(1); // Dump $url to the Tracy debug bar bd($url, 'url'); // The old URLs you want to redirect from (relative to site root) $redirects = [ '/blog/foo/', '/blog/bar/', ]; if(in_array($url, $redirects)) { // Get the blog landing page however suits $blog_page = $this->wire('pages')->get('template=blog'); // Redirect to blog landing page $this->wire('session')->redirect($blog_page->url); } }); When you visit a URL that does not match any page then you'll see the $url variable dumped via the Tracy debug bar. Tracy docs are here: https://adrianbj.github.io/TracyDebugger/#/debug-methods?id=bardump Enter some random letters in the URL to confirm that the hook is firing and you can see the dump. Then try one of your old blog post URLs. If you don't see any dump then the hook is not firing, in this case because ProcessPageView::pageNotFound() is not executing. In which case you have something interfering before PW can attempt to render the page requested in the URL - so probably due to an .htaccess rewrite or something caused by Jumplinks (or another module or hook if you have anything else that affects URLs).
  16. I'd be totally fine with that. It could be a "Don't create field" checkbox and you could even use some custom CSS to put it somewhere subtle and out-of-the-way. That way it's not distracting/confusing for people who use the module in the standard way but is available for those who want it.
  17. That sounds sensible. I guess Pluralize would need to be reinitialised with different settings depending on if a field is being created or not, so you could put that JS into a function with a parameter that switches the type of initialisation and then call that on window load and on checkbox change. Or there are probably other ways too.
  18. Hi @adrian, This will probably sound like an odd request given the name of the module... What do you think about adding an option to not actually create a Page Reference field but only create the templates and pages (if any)? The smart template naming and template restriction features are so useful that I often execute the module and then just delete the Page Reference field because I don't need it. I'm not sure if you or anyone else ever do this, but if I'm not the only one maybe it would be a handy addition to the module?
  19. Sounds like something is interfering before ProcessPageView::pageNotFound can execute. You can check by using Tracy Debugger to dump $url inside the hook and see if the hook is firing or not. If not then it might be caused be something in .htaccess or in Jumplinks. To check you could copy the site to your local machine, replace .htaccess with a clean copy and uninstall Jumplinks - whether it's worth the trouble depends on how important it is to you to get those redirects working.
  20. I can see a few issues, mostly relating to your formatTags setting: 1. The Format plugin is for block-level elements and the <a> element you have included is not block-level. 2. Normally list formatting is applied with the dedicated <ul> and <li> buttons and not via the Format dropdown. 3. You are configuring format tags but you haven't included the Format dropdown in the toolbar, so the format tag options aren't going to be available the user. 4. If you specify format tags beyond those configured by default in CKEditor (p;h1;h2;h3;h4;h5;h6;pre;address;div) then you have to configure corresponding "format_(tagName)" settings. This is the cause of the JS error. From the documentation: 5. Usually you don't want TextformatterEntities applied to a field that is going to contain HTML. If what you are trying to do is remove the heading options from the Format dropdown then you can set Format Tags to "p" only and the NumberedList, BulletedList and PWLink toolbar settings will allow those corresponding tags also.
  21. @Ben Sayers, if you're still having problems and just need a solution to get the redirects working you could hook ProcessPageView::pageNotFound in /site/init.php $wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) { $url = $event->arguments(1); // The old URLs you want to redirect from (relative to site root) $redirects = [ '/blog/foo/', '/blog/bar/', ]; if(in_array($url, $redirects)) { // Get the blog landing page however suits $blog_page = $this->wire('pages')->get('template=blog'); // Redirect to blog landing page $this->wire('session')->redirect($blog_page->url); } });
  22. Check that you have given the role in question the "page-lister" permission.
  23. You need to pass your settings to $config->js() in a renderReady() method. https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/wire/core/Inputfield.php#L1224-L1244
  24. Attempt to log in via the LoginRegister module several times in short period of time using an incorrect password.
×
×
  • Create New...