-
Posts
1,065 -
Joined
-
Last visited
-
Days Won
11
Posts posted by Zeka
-
-
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.
-
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!'); }
-
1
-
-
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.
-
2
-
-
What is the fieldtype of the "tags" field? Page Reference or Select Options Fieldtype?
-
1
-
-
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/
-
3
-
-
-
Have you seen this https://ide.atom.io/ ?
-
1
-
-
You can use getForPage method.
-
3
-
-
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", ]
-
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.
-
MenuItem1
-
-
2
-
-
Hi @abdus
Thank you for explanation and example.
I have read your thread about dependencies but forgot it)))
-
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.
-
One more example from @Robin S
-
1
-
-
Did you declare namespace in your file?
<?php namespace Processwire;
-
1
-
-
Hi @Robin S
Have not tried this module yet, but I'm curious is it possible to restrict matrix types per template basis?
-
26 minutes ago, flydev said:
I'll give you the url tonight
I also would like to participate in testing if needed
-
1
-
-
Hi @flydev
Will it be free/public or commercial module?
-
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?
-
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.
-
1
-
-
Hi @Juergen
Maybe you can use wireRenderFile and pass language variable in arguments and then use getLanguageValue.
-
1
-
-
Just WOW @bernhard
-
1
-
1
-
-
@kongondo thanks that you corrected me, I was not sure about it.
-
Hi @zaib
Are you sure that all of the blog entries are published and visible ( not hidden )?
URLsegments, path hook and original URL
in General Support
Posted
@tpr Thank you for suggestions.
Hook to what?
Alternative template file does not do the job. Pages are still accessible by original URLs.