Jump to content

All Activity

This stream auto-updates

  1. Today
  2. @ArklogicFor actual PW versions, just put your live config settings into config.php and your local development settings into config-dev.php and don‘t upload the dev config to your live site. This works quite well for small sites/teams. In config-dev.php you could use plain PHP to read from .env or add switches to reflect different stages based on a variable, flag etc.
  3. Thank you. I totally agree with you but… The reason I'm doing it this way is I'm using the https://github.com/Toutouwai/CustomAdminMenus plugin — and this is unaware of page permissions. EDIT: I've realised this will do the job. It's not quite what I was after but it's a bit of an edge case anyway and only takes a minute to implement. wireLangReplacements([ 'The process returned no content.' => 'This page is either for administrators only or it doesn’t exist. Please go back and choose another page.', ]); Thanks for your help.
  4. I proposed to either 404 or redirect. So if you redirect to the main admin page and add a message before you redirect, the user doesn't even need to click anywhere and gets there automatically. Better UX IMO. Which items would that be? You can setup your roles/permissions in a way that users only see the menu items for pages/processes they have access to. If your users get access to the page tree, you can use hooks that utilize Page::viewable to remove those pages from the tree that they should not see. You'd have to activate language support (if you haven't already) and then in the settings for each language search through the core translation files to find those strings and then overwrite them.
  5. Thanks for the suggestion. It's slightly different in this instance since there are additional items in the admin that appear in the menu, which I can't remove, and it would just make it look like they're broken if they 404. I was hoping instead to simply override the text of these to make the user experience make more sense: ProcessWire: You don't have access to edit The process returned no content. Even something as simple as a translation would be better: You don't have permission to view or edit anything on this page This page is for administrators only. Please click here to go back to the main admin page. Is that easy to do?
  6. I have quite specific question. I am working on app in processwire which Is for contract and product management. I have already quite lots of pages with imported data. I need to establish link for page(contract) which should be connected with multiple pages (products). Imported data have same numeric field on contract template and also on product template. This field is not a name or title of page. Now is all achievable on fronted where is possible to prepare markup with selected data. But I need to have this connected in backend(admin) - is possible to connect fields between pages 1:n from already created data? Reason for this is to have option to edit connected data in backend ... I would appreciate any advice. Anybody know how to do this?
  7. Resolved. public function init() { $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'addResources'); } public function addResources(HookEvent $event) { $page = $event->object; $this->config->styles->add($this->config->urls->SeoTextWidth . "SeoTextWidth.css"); $this->config->scripts->add($this->config->urls->SeoTextWidth . "SeoTextWidth.js"); }
  8. I created this as a hook and it's working great, so I decided to turn it into a module to share. We have option in the backend to calculate number of characters but this script is calculating the width of the text as it should be displayed in Google's SERP for the meta title and meta description. However, it's not working for some reason (that I can't identify). This (primitive) module should load on the (any) page edit in the backend. As you can see, it's supposed to load two files. I'm not sure why it's not functioning. // Module: SeoTextWidth.module class SeoTextWidth extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => 'SEO field Text Width module', 'summary' => 'This module is calculating width of text in the fields named seo and desc.', 'version' => 1 ]; } public function __construct() { parent::__construct(); } public function init() { $this->addHookAfter('ProcessPageEdit::render', [$this, 'addResources']); } public function addResources(HookArgs $args) { $output = $args->getOutput(); $page = $args->wire('page'); // Check if we're on the page edit view for a valid page if ($page && $page->editable()) { $jsUrl = $this->config->urls->scripts . 'SeoTextWidth.js'; $output->append("<script src='$jsUrl'></script>"); $cssUrl = $this->config->urls->styles . 'SeoTextWidth.css'; $output->prepend("<link rel='stylesheet' href='$cssUrl' />"); } return $output; } }
  9. @ryan, Can you have a look at this, and point us into the direction how to get this into pw3 / pw4 ? Being supported /maintained by the community. Basically an auto install by providing a preconfig or .env variables.
  10. Yesterday
  11. I somehow managed to miss this reply. Thank you for both of your replies, @Robin S! I did manage to get this working, with some oddities here and there that had to be worked through due to how I was checking/setting access permissions. I chose not to explicitly set permission for each and every template per role since I'm using a field that's added to the templates to determine access, so it seemed doubly difficult to do that, and my hope was that inheritance would work properly most of the time. So far that's fairly true, with occasional exceptions (ex: nested repeaters since repeaters have their own system templates). It felt a little hack'ish but I checked against the template name and if strpos() found a match to "repeater_" against $page->template->name, then I'd allow access to the edit method (add didn't cause an issue the way I had it written). I wasn't sure how else to check if a template of a page being checked for access belonged to a repeatable fieldtype.
  12. As far as I can tell, that's the way to do it. Assuming your repeater field is called 'my_repeater_field' and it contains a field called 'foo' that you want to add a make-shift markup field above, here's what you'd do: $wire->addHookAfter('InputfieldWrapper::render', function(HookEvent $event) { if(!$event->object->children->count) return; if($event->object->children[0]->name!="my_repeater_field") return; $event->return = str_replace( "<li class='Inputfield InputfieldText Inputfield_foo_repeater", " <li class='Inputfield'> <label class='InputfieldHeader'> my custom repeater markup field </label> <div class='InputfieldContent'> content goes here </div> </li> <li class='Inputfield InputfieldText Inputfield_foo_repeater", $event->return ); });
  13. @wbmnfktr just tried it locally and got the same error "Unknown character set: utf8mb4mb4". Not sure if it was always like this or if it's a new thing. Usually I stick with the default utf8 formatting. But for the support of emoticons, I try to use"utf8mb4" lately. Would be nice if the site exporter/importer takes care of this. Edit: If I keep default utf8 settings, I can install the utf8mb4 formatted site, but the fields containing emoticons are empty.
  14. Hello Bernhard, Thank you again! It was very instructive. No doubt includes are essential. I didn't know if I had to post it here or in the RockFrontend module topic. I'm converting and redesigning an old ProcessWire website for a non-profit association. It contains 3 FormBuilder forms. In _init.php, I have this code now (the same I had but I made changes so that it works with only one template): // FormBuilder if($page->template == "form-page" && $page->id == 1061) $form = $forms->render("contact"); else if($page->template == "form-page" && $page->id == 1059) $form = $forms->render("benevolat"); else if($page->template == "form-page" && $page->id == 1060) $form = $forms->render("soutien"); else $form = null; And in /site/templates/sections/main.latte, I have this line among other things: {$form|noescape} (I can"t escape again from having to use the |noescape filter...) In the old website, in _head.php and in _foot.php I have respectively: if($form) { echo $form->styles;} if($form) { echo $form->scripts; } How could something like the following work? (with the condition that $form exists or that $page->template == 'form-page')? In _init.php, // RockFrontend $rf = rockfrontend(); $rf->styles() // add the base uikit theme ->add('/site/templates/uikit/src/less/uikit.theme.less') // add default folders like /sections and /partials ->addDefaultFolders() // add FormBuilder styles on condition ->addIf($form->styles, $form) // minify on production ->minify($config->debug ? false : true); $rf->scripts() // load uikit ->add('/site/templates/uikit/dist/js/uikit.min.js', 'defer') // load custom javascript of this project ->add('/site/templates/scripts/main.js', 'defer') // add FormBuilder scripts on condition ->addIf($form->scripts, $form, 'defer') // minify on production ->minify($config->debug ? false : true);
  15. This is a quite common problem, but I haven't seen a good solution for it. Probably there is none, because the problem is not the technical solution, the problem is the problem itself. Does that make sense? We have different languages and we have different regions, so we have a multidemensional thing to show an a single-dimensional website. Even if we had a technical solution (like url segments or page tree) the problem is still a problem in my opinion, because content get's tedious to manage. But I'd be curious if anybody has found a good solution for it, as I've once talked to someone looking for something similar and he said PW would not be a good solution for this task. I don't think that this is true, but maybe my feeling is wrong and there are other platforms that already solve that challenge properly? Please let me know if you know any. --- I think if I'd had to build this I'd go with the page tree for regions and a global "data-pages" section for pages that can be shared as needed by the region pages. But it depends on the priorities of the specific project. Maybe reusing content is more important, maybe something else... What I could think of would look like this: -- home -- content -- foo -- bar -- baz -- about us -- europe -- about us -- asia -- foo -- bar -- about us -- america -- baz so all content would go into /content and all the regions would be reflected in the tree and only reference those content pages. Routing would be easy and all regions would support all language, eg /en/europe/about-us Think of it similar to a menu builder. Editing would get a little more complex, but I think that's a small price to pay and I can't think of an easier solution to this multi-dimensional problem 🙂
  16. Many thanks @gebeer for this. Some of what is needed could certainly be handled by the page tree. I hadn't tough of that. However, I think I'll also look through the URL hooks idea as that might be the only way to handle some of the more complex issues.
  17. @gebeerThanks for your long reply which I am reading only now. I have other things to do right now so I'll come back on this later and try everything you said and edit this post to let you know how it goes. Edit : I have eventually managed to uninstall Process Login History by doing what @gebeersuggested (rename, then missing > remove from database). The problem persisted… I have also checked the XHR response with Firefox and got the « server error » after about 60 seconds trying to load the pages tree… I guess I won't have any answer from the host admin until next week 😞 I have no idea what else to try. I have tried everything I could think of (htaccess modifications, uninstalling modules, removing parts of my site to limit server loading…)
  18. Keep adding infos : I can confirm that as a guest, the site works as expected. I can follow any link and the result appears quite fast. As soon as I log in, everything gets stuck quite fast (except pages that had been already cached somehow)..
  19. I'd take a different approach and use hooks Page::viewable and Page::editable in templates/admin.php to either throw a 404 or to redirect to some default page they can view. In either case you can add a message or error that will be shown at the top of the page.
  20. Can someone confirm issues when importing a profile with utf8mb4? My case: I exportet my latest site-profile yesterday and tried to install it in a new project today and it got terribly wrong. I could fix and finish the installation by installing everything with just utf8 and later changing the config to uft8mb4. I looked into the export and while the db dump clearly shows utf8mb4 it's not saying anything about it in the config.php - which could be totally fine. Yet trying to install it fails. Here a short excerpt from the install log which was over 600 lines in total: You might notice this weird utf8mb4mb4 in the second line. And I guess that's the issue here but I can't find it in any of my exports. Versions used: ProcessWire 3.0.238 Export Site Profile 5.0.1
  21. Yes, this is what I would go for. Sth like domain.com/fr/market1/, domain.com/fr/market2/ etc. so you have segments /language/market/ You can either 1. reflect this in your page tree -home --market1 ---page --market2 ---page 2. use URL segments. This would make the routing more complex. 3. You could also use URL hooks with named arguments and do your routing from there. For 2 and 3 you need to make sure that the URLs with market segments resolve to a 404 without segments/hooks in place. I've done something like this at https://www.ziehm.com/en/products/ and https://www.ziehm.com/en/us/product-portfolio/ where /us/ is the market segment. In this case we solved it through the page tree structure. Drawback is that similar pages under default market (no market segment) and us market need to be maintained seperately. EDIT: to avoid maintaining duplicate pages for different markets, you can have a markets parent with markets as children with templates markets and market respectively: Market pages: -markets --europe --asia --africa Then have a page reference field that allows selection of 1 or more markets. Now you use this field in combination with prices or other things. In the rendering logic you can get the price for market by URL segment. You'd need to have the market chooser direct to the respective market segments of the page. In said project we have a market selector page for each market with the languages to choose from https://www.ziehm.com/en/us/market-selector/ If you have those market pages in the tree, you can also link markets to available languages for that market. It was fun and challenging to work that out for said project.
  22. I was reading through the thread and had the intution that Login History might have sth to do with your problem. Then I read that. To manually disable the module, you can rename the module folder to .ProcessLoginHistory . Then you can do a modules refresh and you should see the ProcessLoginHistory listed under "Missing" and can remove it from there from the DB. Maybe this will help. Still I think you are having permission issues on the new server since you can't delte old folders. Do you have ssh access to the server? If not, the server admin should be able to help with those issues. The 502 Proxy error signifies a communication breakdown between servers, often caused by issues like server overload, network problems, or configuration errors. Again, hard to debug that from the outside and the server admin should see what is happening exactly. But I guess it is some kind of overload problem caused by too many DB requests or the like since you get that server error too many SQL connections. When you login as Teacher and the page tree doesn't load, you can open the browser dev tools and check for the Responsetab of the XHR request that is happening to fetch the page tree data. In Firefox this should look something like this (where yours likely has a 500 error):
  23. Hi folks, A lovely client of mine is looking to extend their PW site to include region or 'locale' specific content (e.g. a differently laid out home page, local product prices etc.) for certain world regions. These would be chosen by the user from a header menu and the choice retained for a sensible amount of time. The site already has languages presented using the native PW language functionality so their current URLs are in the form mysite.com/fr (using French as an example). We have discussed some different ways of handling the locales. We have ruled out out subdomains for obvious maintenance and SEO reasons. The next thought was browser cookies. However, if possible I'd like to handle the locale specific content server side if possible, rather then sending it all to the browser and using JS or similar to show the content for that locale. One question they have asked is 'can we use and additional URL segment to achieve this'? This would enable direct linking to a specific page / language / locale. For example, French speakers in Canada could use 'mysite.com/fr/ca' or 'mysite.com/ca/fr' (we don't mind what order the language / locale appear if that matters). Has anyone come across / found a solution for this type of question? If so, how did you handle it? Or, is there an alternative solution for this that I'm missing? As always, any and all suggestions / thoughts welcomed and appreciated!
  24. Well, poor feedback for now, sorry… My site is still not working. And I'm completely stuck. I have contacted the host admin to see if he has an idea (weird thing : my site folder has 770 permissions and I can't change it via FileZilla although it belongs to my user/group and I have put it there myself (twice ! and I can't delete the old folder site_), the same for assets_ !) Anyway, I constantly have 'server error' too many SQL connections. I've tried avoiding my LazyCron jobs in my _init file. Not better. I've noticed that if I delete all cache/cookies, I can get to the login age for the backend. When I log in, twi cookies get installed : wires and wires_challenge. I go to the backend (as a teacher) but Pages Tree never loads and then I get the Server Error whenever I go to antoher page. If I manually delete the 2 before-mentionned cookies, I can do the process again. If I log in as Admin, the Pages tree loads fine and all backend works fine. I have no idea why such a different behavior… As admin though, I was able to unsinstall some modules as stated in my previous posts, but if I try uninstalled Process Login History, I get the « Server error » (after about 60 seconds) and this module stays there… (that's how I have notices my permissions issues I've talked in the beginning of this message). Sorry for this « messy » message again, but I'm losing myself (and my site) on these issues… I have no idea if it's a server problem or a problem on my side (or both) and it's killing me… I try to be patient and wait for an admin to answer my questions about those file permissions issues. Meanwhile, I keep trying some stuff, reading around the forum trying to find clues… And I give little news here in case someone has a clever idea or stays interested in how this situation will end up 🙂 Thanks anyway for taking the time to try and unserstand my worries. Edit : After wandering in the backend as admin, I click 'View site' and get the "server error"… Insisting a little, it eventually works and comes back on another page… driving me crazy ! Edit 02 : In fact, the error is « Proxy error » and has a 502 mention in my debugging tool (which I don't really know how to use, sorry…)
  25. When a user goes to a page in the CMS that they don't have permission to access you get two messages: ProcessWire: You don't have access to edit The process returned no content. How can I use hooks to override these messages? Ideally for point 2, I'd like to use HTML. Thanks.
  26. Hi @Michael Lenaghan There is no "Mark as solution" button here as far as I know. You have to edit the post title and add "Solved" or whatever you think appropriate. Gideon
  1. Load more activity
×
×
  • Create New...