Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. @Ivan Gretsky You still can access the site via https://archive.org/web/
  2. @PWaddict https://processwire.com/api/ref/role/
  3. Hi. I have such selector: // selector as associative array $selector = [ 'template' => 'diagnostic', 'diagnostic_code%=' => '000009', 'limit' => '20' ]; produces this (from PW debug panel): // selector query template=diagnostic, diagnostic_code%=9, limit=20, status<1024 // sql query SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_diagnostic_code AS field_diagnostic_code ON field_diagnostic_code.pages_id=pages.id AND (((field_diagnostic_code.data LIKE '%9%' ) )) WHERE (pages.templates_id=65) AND (pages.status<1024) GROUP BY pages.id LIMIT 0,20 The same selector, but in string format $selector = "template=diagnostic, diagnostic_code%=0009, limit=20"; produces this: // selector query template=diagnostic, diagnostic_code%=0009, limit=20, status<1024 // sql query SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_diagnostic_code AS field_diagnostic_code ON field_diagnostic_code.pages_id=pages.id AND (((field_diagnostic_code.data LIKE '%0009%' ) )) WHERE (pages.templates_id=65) AND (pages.status<1024) GROUP BY pages.id LIMIT 0,20 As you can see (from selector and SQL queries) it trims leading zeroes when I use the selector as an associative array. Is it a bug or I miss something? Thanks, Eugene.
  4. https://github.com/ryancramerdesign/ProcessWire/issues/1969 This issue looks similar to that you posted and it was fixed.
  5. @Gadgetto There is no problem with getting pages with the name field. Just use default language value as selector value. Getting page by name has some pitfalls, $pages->get() return the first found page, but you can have several pages with the same name under different parents, so you should specify parent selector to make sure that you are looking for the needed page. So basically you can use this in English and Deutsch languages d($lang->title); // english d($pages->get("name=sample-page")->title); // Sample page $user->language = $languages->get('deutsch'); // change user language to deutsch d($pages->get("name=sample-page")->title); // beispiel-seite But if you want to find your page by Deutsch name: $lang = $languages->get('deutsch'); get deutsch language d($lang->title); // deutsch d($user->language->title); // english d($pages->get("name{$lang}=beispiel-seite")->title); // beispiel-seite
  6. Ok. First of all, make sure that you know how selector works in PW. https://processwire.com/api/selectors/ You can get a page by its id: $some_page = $pages->get(2030); // get page by id echo $some_page->title; echo $some_page->summury;
  7. @Gadgetto What do you mean with 'select a page'? Does this section answer your question? https://processwire.com/api/multi-language-support/multi-language-fields/#how-language-fields-work
  8. @Gadgetto foreach ($languages as $language) { ... $hreflang = $page->getLanguageValue($language, 'languagecode'); // ... } As you wrote, you have added 'languagecode' field to language template, but in your snippet, you are trying to get value from 'languagecode' field from $page which, I assume, is using home or basic-page template. This code will work if you add 'languagecode' field to a template which used by the current page.
  9. @Gadgetto foreach ($languages as $language) { ... // $hreflang = $page->getLanguageValue($language, 'languagecode'); $hreflang = $language->getLanguageValue($language, 'languagecode'); ... }
  10. @PWaddict https://github.com/processwire/processwire/blob/dev/wire/modules/AdminTheme/AdminThemeUikit/AdminThemeUikit.module#L43 Change it to false.
  11. @bernhard Just tested on 3.0.117 d($this->wire->modules->find('name^=Inputfield')); d($this->wire->modules->find('name^=Inputfield')); Both return 37 items. Is it specific to 'UikitTheme' names?
  12. @ryan Thanks for updates. In the blog post for 3.0.117 new 'WireArray::new' method was introduced but in 3.0.118 it was removed and now we have new API functions (WireArray($items) and PageArray($items). Maybe the blog post for 3.0.117 should be changed to reflect current implementation (as blog posts currently are part of docs)?
  13. There is a notice about in field configuration screen If the field is not “required” then minimum length is only enforced when a value is present. but it also true for maximum length. What I would recommend is to not enforce limits, but just notice that only 200 chars will be outputted on the fronted. For text truncate you can use these handy functions: https://processwire.com/blog/posts/processwire-3.0.101-core-updates/
  14. @theoretic Actualy there are two options for writing selectors as associative arrays and reqular arrays. https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#selector-engine-array-support
  15. @mntob Yes, it's possible. Take a look at Selectors docs. https://processwire.com/api/selectors/ Your selector shoud be like template=itemProduct1ingle|itemProduct2ingle, sort=-created
  16. @adrian I tried such hook (without conditions) on PW 3.0.105 and TD 4.10.22 and it works as expected. I got 360 dumps. So, yes, probably it is somehow relative to new tabs in dump panel. wire()->addHook("Page::path", function($e) { bd($e); $page = $e->object; $e->return = "/{$page->name}/"; });
  17. @adrian Thanks, reducing of the maxDepth depth helped. But it's strange, as in earlier versions I have used bd calls in such hooks without maxDepth tuning.
  18. Hi. Description in the docs for these methods says 'Return the page path in the current user's language, or specify $language argument (Language object, name, or ID).'. But from what I see in the code it returns the page path in default user's language or in specified language.... /** * Add a Page::localPath function with optional $language as argument * * event param Language|string|int Optional language * event return string Localized language path * * @param HookEvent $event * */ public function hookPageLocalPath(HookEvent $event) { /** @var Page $page */ $page = $event->object; $language = $this->getLanguage($event->arguments(0)); $event->return = $this->getPagePath($page, $language); } /** * Add a Page::localUrl function with optional $language as argument * * event param Language|string|int Optional language * event return string Localized language URL * * @param HookEvent $event * */ public function hookPageLocalUrl(HookEvent $event) { /** @var Page $page */ $page = $event->object; $language = $this->getLanguage($event->arguments(0)); $event->return = $this->wire('config')->urls->root . ltrim($this->getPagePath($page, $language), '/'); } /** * Given an object, integer or string, return the Language object instance * * @param int|string|Language * @return Language * */ protected function getLanguage($language) { if(is_object($language)) { if($language instanceof Language) return $language; $language = ''; } if($language && (is_string($language) || is_int($language))) { if(ctype_digit("$language")) $language = (int) $language; else $language = $this->wire('sanitizer')->pageNameUTF8($language); $language = $this->wire("languages")->get($language); } if(!$language || !$language->id || !$language instanceof Language) { $language = $this->wire('languages')->get('default'); } return $language; } Am I right? Should I reise an issue to aks Ryan to correct it?
  19. @adrian While wokring on a site I faced a problem with hook and bd call in it. wire()->addHookAfter("Page(template=blog-category)::path", function($e) { $page = $e->object; bd($e); $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $pageName = $page->localName($language, true); $e->return = $langSegment . "$pageName/"; }); Such hook leads to 'Fatal error: Allowed memory size'. I have tested it on three different installations, got the same result even on clean installation with only TracyDebugger module. PW 3.0.117 and 3.0.116, the latest module version, PHP 7.2.4.
  20. Hi. I have hooks to Page::path like wire()->addHookAfter("Page(template=blog-entry|blog-category)::path", function($e) { $page = $e->object; $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $pageName = $page->localName($language, true); $e->return = $langSegment . "$pageName/"; }); This hook changes pages path in frontend and 'view' action in PageTree, but it doen't in 'view' tab on page edit screen and page url in config tab of page edit screen Is there a way (hook) how to change page path in these places? (at least view links). Thanks, Eugene.
  21. No, it's selectors as associative arrays: https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#new-selectors-as-associative-arrays
  22. Zeka

    ProcessWire on the web

    [I was asked to remove the link for now]
  23. https://github.com/processwire/processwire/blob/master/wire/config.php#L777 https://github.com/processwire/processwire/blob/master/wire/config.php#L788 But I think that the best route is to update your URLs and make redirects in Jumplinks.
  24. Hi. I declare a new wire variable in the _init.php (prepended file). $wire->set('general', WireArray::new($general_info)); In the template file '$general' variable is not populated, but I can access it via wire('general') or $wire->general. So my question is why it behaves in that way? Prepended files are just included during the rendering process, but in some forum posts, I have seen examples where declared variable in _init.php is populated in a template file. So far all 'global' variables should be declared in init.php or ready.php?
×
×
  • Create New...