Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. @tpr Thank you for suggestions. Hook to what? Alternative template file does not do the job. Pages are still accessible by original URLs.
  2. Hi, community. I'm using a hook to path to change URL of some pages. wire()->addHook("Page(template=services-category|service)::path", function($e) { $page = $e->object; $e->return = "/{$page->name}/"; }); Then in template where I enable URL segments, I use code like if (input()->urlSegment(1)) { $pagename = input()->urlSegment(1); $match = pages()->findOne("template=services-category|service, name={$pagename}"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } Typical. I have the template file for "service" template, so I can use $page->render() and because of it, these pages are also accessible from their old URLs. So my question is how to prevent these pages being accessible from their original URLs without removing template file for their template? Eugene.
  3. try { $form->processInput($input->post); $session->CSRF->validate(); } catch (WireCSRFException $e) { echo "Processing aborted. Suspected attempt to forge the submission. IP logged." . $e->getMessage(); /* * Some code to execute whenever the token gets spoofed * Like sending a notification mail with the spoofer's IP address */ die(); // live a great life and die() gracefully. } or // when processing form (POST request), check to see if token is present if($session->CSRF->hasValidToken()) { // form submission is valid // okay to process } else { // form submission is NOT valid throw new WireException('CSRF check failed!'); }
  4. How results are sorted if you don't specify a "sort" in your selector In $page->children() and $page->siblings() the results are automatically sorted by the page's default sort field that you specify in the admin. If not specified in the admin, the pages will be sorted by the order they are placed in the admin. This behavior can be overridden by specifying your own "sort=[property]". With $pages->find() and $page->find(), if you don't specify your own "sort=[property]", the results are sorted according to MySQL's text searching relevance. If no text searches are performed in your find(), the results are unsorted. As a result, it is generally a good idea to include a "sort=[property]" when using $pages->find(), especially if you care about the order and your find() operation is not text/relevance related.
  5. @zaib What is the fieldtype of the "tags" field? Page Reference or Select Options Fieldtype?
  6. Zeka

    htaccess help

    Hi @rst You can find a lot of recommendations from Ryan how to optimize such cases https://processwire.com/blog/posts/optimizing-404s-in-processwire/
  7. @Macrura Very cool! What about image field? Is there support for this type of field?
  8. Have you seen this https://ide.atom.io/ ?
  9. Hi @heldercervantes You can use getForPage method.
  10. Hi! Is there some helper method that can extract fields values to an array like it do WireArray::explode()? $data = $page->explode(["title", "desc", "name"]); /// [ "title" => "value", "desc" => "value", "name" => "value", ]
  11. Hi @kongondo I have this setup: MenuItem1 Submenuitem_01( allowed children) SubmenuItem_02 ( allowed children) MenuItem2 Submenuitem_03 ( allowed children) SubmenuItem_02 ( allowed children) I'm using getMenuItems for building my menu, but the issue is that I get children of Submenuitem_02 as children only of the last Submenuitem_02 ( parent_id = id of the last Submenuitem_02 ), but I expected that I will get duplications of children pages with right parent_id for every Submenuitem_02 Of course, I can get children in my custom function but I think that in this case, getMenuItems doesn't work as expected and could be improved. What do you think about it? Thanks, Eugene.
  12. Hi @MrSnoozles Have you seen this thread
  13. Hi @abdus Thank you for explanation and example. I have read your thread about dependencies but forgot it)))
  14. Hi. I have found very useful to store some data like translations and some global settings inside $wire object by $wire->set("custom", $custom); What are pros and cons of using it? And there is the thing in the docs that I can't understand: Injection of dependencies to Wire derived objects: $this->wire($widgets); Can somebody explain what are dependencies in this case? Thanks, Eugene.
  15. One more example from @Robin S
  16. Did you declare namespace in your file? <?php namespace Processwire;
  17. Hi @Robin S Have not tried this module yet, but I'm curious is it possible to restrict matrix types per template basis?
  18. @flydev I also would like to participate in testing if needed
  19. Hi @flydev Will it be free/public or commercial module?
  20. Hi @kongondo Thank you for so great module! I use 0.1.7 version of module and get PHP Notice: Array to string conversion in ...\ProcessMenuBuilder\MarkupMenuBuilder.module:922 Here is how I use it $menu_page = pages(1023); if($lang_name == "ukrainian") { $menu_page = pages(1024); } $menu = $menuModule->getMenuItems($menu_page, 1, [ "current_class_level" => 2 ]); Changing this line $menuItems = ''; to $menuItems = array(); fixes it. Am I missing something?
  21. Hi @sreeb Do you cache results of searches? I have a similar project with a lot of filtering options. I use WireCache for caching search results ( PageArrays) and MarkupCache for result cards. It works quite fast on shared hosting.
  22. Hi @Juergen Maybe you can use wireRenderFile and pass language variable in arguments and then use getLanguageValue.
  23. @kongondo thanks that you corrected me, I was not sure about it.
  24. Hi @zaib Are you sure that all of the blog entries are published and visible ( not hidden )?
×
×
  • Create New...