Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. If I'm not mistaken it saves field value, but not the whole page. https://github.com/processwire/processwire/blob/master/wire/core/PagesEditor.php#L113
  2. Thanks, @abdus for so quick response. You are right, I don't get "category" page because of missed "echo"; And this return $this->halt(); prevents render of "categories" page. From your code: $name = sanitizer()->pageName(input()->urlSegment1); https://processwire.com/api/ref/input/url-segment/ Docs say that urlSegments are already sanitized as page names. Thanks once again!
  3. @abdus Thank for your example. I have tried to test. It looks like I don't fully understand this approach, would be nice to get clarification. Here is my setup In site/init.php wire()->addHookBefore('TemplateFile::render', function (HookEvent $event) { // skip if AJAX if ($event->config->ajax) return; /** @var TemplateFile $templateFile */ $templateFile = $event->object; // Skip admin pages if (strpos($event->input->url, $event->config->urls->admin) === 0) return; // check if this is a partial template, if so, stop $fileDir = pathinfo($templateFile->get('filename'), PATHINFO_DIRNAME); $templatesPath = $event->config->paths->templates; if (realpath($fileDir) !== realpath($templatesPath)) return; $templateName = $templateFile->page->template->name; bd($templateName); $prepends = [ 'routes' => $templatesPath . "{$templateName}.routes.php", 'before' => $templatesPath . "_init.php" // like your _init.php ]; // then comes the actual template file $appends = [ 'after' => $templatesPath . "_main.php", ]; foreach ($prepends as $name => $file) { if (file_exists($file)) $templateFile->setPrependFilename($file); } foreach ($appends as $name => $file) { if (file_exists($file)) $templateFile->setAppendFilename($file); } }); In templates/categories.routes.php // we are only using 1 URL segment, so send a 404 if there's more than 1 if($input->urlSegment2) throw new Wire404Exception(); // we have 1 URL segment in page URL if ($input->urlSegment(1)) { $pagename = $input->urlSegment(1); $p = pages()->findOne("template=category, name={$pagename}"); if ($p->id) { $p->render(); } else { throw new Wire404Exception(); } } In templates/_init.php // Include helper methods for templates render require_once("./helpers/convenience-methods.php"); require_once("./helpers/functions.php"); region("header", renderGlobal("header")); region("masthead", renderGlobal("masthead", $viewData)); region("footer", renderGlobal("footer")); region("scripts", renderGlobal("scripts")); In templates/categories.php $viewData["categories"] = pages("template=category"); region("content", renderView("categories", $viewData)); In templates/_main.php <?=region("header");?> <?=region("masthead");?> <?=region("content");?> <?=region("footer");?> With this setup with any URL segment1, I got render "categories " page, not "category" from $p->render(); @szabesz Sorry for not being clear, with code examples it would be more clear what I meant.
  4. Hi. I'm using delayed output strategy where in "_init.php" (prepended template) file I define my default regions /fields / etc. For some part of pages, I have to use URL segments and the logic of handling urlSegments is placed in templates files. $p = pages()->findOne("template=knowledge-base-category|knowledge-base-item, name={$pagename}"); if ($p->id) { $p->render(); } else { throw new Wire404Exception(); } In this way when $p-> id statement is true, all circle of _init.php> template file> _main.php repeats. So it takes twice as much time to render one page because a lot of heavy things happen inside _init.php which is called twice. There are two ways that I see how to deal with that: 1. Don't use urlSegments. ))) 2. Move heavy logic from _init.php under segments code, but in this way, I get a lot of duplicated code in my template. How do you handle this cases?
  5. Hi @noelboss You can play with "Label field" options. Select Custom format and put something like {parent.title}. Are you talking about front end editing?
  6. In terms of the 2nd question. Yes, I save settings page of a field after every change. Once again: 1. Create a text field and enable Ion Slider ( Do not load any skin or setting of the slider ). Save. 2. Put this field to any template. Save. 3. Create a page with this template. Slider won't work because there are no params. Save. 4. Load any params in the setting of the field. Save. Params are loaded and visible in textarea. Go to the page that you've created and refresh the page. Slider won't work. 5. Change skin in settings. Save. Go to page. Slider works. Here is screencast from the 3rd step.
  7. Hi @Macrura Just tested the latest version from your repo and it works with repeaters partially. It works in two cases: 1. If "Repeater item visibility in editor" set to "Always open". 2. If "Repeater item visibility in editor" set to "News items open, existing items collapsed" (default option) and you have some other field with the slider on this page, but outside of repeater items or any other dynamically loaded element. The same with Repeater Matrix. And I have found one more strange behavior: 1. Create field and load any predefined settings (works) 2. Clean settings textarea and choose any other predefined settings after that it doesn't work. 3. Change "slider skin" setting to any other and it will work again. Have tested it with Profield Textareas and it works.
  8. Hi @Macrura Nice module, but doesn't work in repeater
  9. I have opened an issue for it. https://github.com/processwire/processwire-issues/issues/366
  10. Hi @szabesz Thank you for confirmation. Yes, when adding % I got "Bad request! Your browser (or proxy) sent a request that this server could not understand." PW 3.0.74
  11. Hi! I have this code in my page template file: <?php namespace Processwire; if($input->urlSegment2) throw new Wire404Exception(); if ($input->urlSegment(1)) { $pagename = $input->urlSegment(1); $p = pages()->findOne("template=knowledge-base-category|knowledge-base-item, name={$pagename}"); if ($p->id) { $p->render(); } else { throw new Wire404Exception(); } } else { $viewData["categories"] = pages("template=knowledge-base-category"); region("content", renderView("knowledge-base", $viewData)); } ?> Max urlSegments is set to 4. Should URL segments end with trailing slash is set to Yes. Everything works as expected until I try to access any URL which ends with any special character like: site.com/current-page/real-page/not-real-page) or site.com/current-page/real-page/not-real-page@ In those cases, I get rendered homepage instead of 404 page. Is there something obvious that I missed?
  12. Storing user data in a session is a good way, but if the question in collecting as much user data as possible I would save every answer on each step. In that way, I will have answers from not finished quizzes/surveys.
  13. There is one more which is bit different from Opera or Chrome, but very useful for web develepers https://blisk.io/
  14. Hi @helmut2509 Change user language in profile, then all title of pages will be in german.
  15. @szabesz and @gmclelland Thank you for tests. Of course, I have tried different versions of PW with and without multi language support in Opera, Chrome and IE Currently, I was able to track it down to this: 1. Create image field. 2. Set default image grid mode to square grid images ( it set by default ) and create page with this template/field 3. When the page loads there no indication that some type of grid is selected. 4. Try to rename image and you get this js error. Then if you choose any of image grid you will be able to rename the image. Could you please check this behavior?
  16. Hi. When I try to rename uploaded images in image field I get js error in console. Error: cannot call methods on sortable prior to initialization; attempted to call method 'disable' I have opened an issue for it, but Ryan can't duplicate it, so it's still not closed. https://github.com/processwire/processwire-issues/issues/290 It would be great if somebody from the community can confirm it.
  17. https://processwire.com/blog/posts/processwire-3.0.40-core-updates/#tips-and-tricks
  18. Hi @Juergen First of all, you have to be sure that your defined setting in cache disable variables is correct. To test it try to put * in GET or POST field in settings and try to submit the form.
  19. I had a situation when I needed to get next repeater item and I also was able to get it working only with "include=all". I'm not sure, but it looks like normal behavior as these pages are under "admin" branch.
  20. Hi @Karl_T Take a look at this module https://github.com/plauclair/AutodetectLanguage/blob/master/AutodetectLanguage.module
  21. You definitely should take a look at URL segments. The power of URL segments is that your URL structure can be different from you page tree structure and in your case, as, for me, it is highly desirable. I think that is not a good way to place products under categories because some products can be relative to several categories. How will you handle it?
  22. Hi @OLSA Because SEO is very important in that kind of business/site I would first of all stick to its requirements and that to other things like the usability of administration etc.d In your second example, you can change "showers and bathtubs" to something more general like "bathroom". In that case, you will have additions keyword in your URL. If your page name includes stop words (and, or, but, of, the, a, etc.), it's not critical to putting them in the URL. You don't have to leave them out, either, but it can sometimes help to make a URL shorter and more readable in some sharing contexts. Use your best judgment on whether to include or not based on the readability vs. length. As for best URL structure, I would recommend "site.com/bathroom/showers/product". You can do it by using URL segments, so you can have desired page tree in admin and perfect URL structure on the frontend. Of course, it's much more work and there is a lot of small things like canonical links, redirect etc that you have to think about. As another way to make your URL shorter you can move only last "product" part to "products", so you will have "products/product". Don't forget to use schema.org or other for breadcrumbs.
  23. Hi @sirhc 1. Set memory_limit to a higher value. 2. Use ImageMagick https://processwire.com/blog/posts/processwire-3.0.10-expands-image-resize-options/ 3. Use client-side image resizing https://processwire.com/blog/posts/processwire-3.0.63-adds-client-side-image-resizing/
  24. Hi @Gideon So Thank you for the reply. I have seen this module, but from the description, it looks like it's possible to restrict page tree to only one branch. Am I mistaken?
  25. Hi! I need to restrict page tree to two branches of pages under homepage. And I don't want to show not editable pages for a user in page tree. What is the right way to do that?
×
×
  • Create New...