-
Posts
1,065 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zeka
-
@Macrura I have several hooks to before/after TemplateFile render method and typically I can exclude PW backend like $templateFile = $event->object; if ($templateFile->page->template == 'admin') { return; } or if ($this->wire('page')->template->name == 'admin') { return; } But these checks fail for rendering settings pages and hooks are executed also for those template files in the admin panel and I get "PHP Notice: Trying to get property of non-object" as $this->wire('page') = null and there is no $event->object->page->template. I'm not sure that it is directly relative to SettingsFactory, so I would ask you to check this behavior.
-
Hi @WebMaster As far as I know, current only ImageExtra module adds support for additional fields for images. Native support for additional properties in image/files fields is on the roadmap for 2018. For now, the most flexible route for you is to create a page for every image, in that way you will get all PW features. There is module that can help with this approach https://github.com/mr-fan/AutoImagePages Do you mean that you can't sort and search by custom ImageExtra fields?
-
What I would really like to see is more expanded multilanguage support in the core as 95% of my sites is ML. Very often I need to have some pages available only in non-default languages and every time I have to reinvent the wheel with custom logic. Almost in all modern CMSs (Statamic, Craft, October ..) you can separately publish or unpublish pages for every language even default. There are @adrian's module and request which intended to solve this issue via a module, but as I said, I think that it should be in core.
-
Uncaught ArgumentCountError: Too few arguments to function
Zeka replied to Peter Knight's topic in General Support
Hi @Peter Knight $thumb = $image->size($width, $height, $options); $width and $height are not optional arguments. https://processwire.com/api/ref/pageimage/size/ -
So at least we have more than 8800 sites using Processwire https://publicwww.com/websites/"X-Powered-By%3A+ProcessWire"/ @jmartsch take a look at this link
- 38 replies
-
- 12
-
Take a look at these examples
-
I think that it's normal behavior as fieldset and fieldset_end are separate fields, so you have to clone each of them.
- 7 replies
-
- duplicate fields
- fieldsetclose
-
(and 2 more)
Tagged with:
-
Hi @encho I've never used this module, but as far as I see there are comments.js and comments.css which you have to include on your page. Here is repo of this module https://github.com/processwire/processwire/tree/dev/wire/modules/Fieldtype/FieldtypeComments Hope it helps.
-
There is also 'X-Powered-By: Processwire' in response headers. $config->usePoweredBy = false; // to prevent it output
-
Add additonal settings to image field in template context
Zeka replied to Juergen's topic in API & Templates
@Juergen In PW 3.0.87 there were some updates to field/template context settings and now you can change field settings in the context of other templates through admin UI. https://processwire.com/blog/posts/pw-3.0.87/ Maybe this update has changed something in core that prevents your hook to work. -
Is it possible to set API variable in prepend files ?
Zeka replied to Zeka's topic in API & Templates
Bump -
Hi. Not sure that it's important but here is my setup: // site/init.php wire()->addHookBefore('PageRender::renderPage', function (HookEvent $e) { /** @var Page $page */ /** @var HookEvent $event */ /** @var Template $template */ $event = $e->arguments(0); $options = $event->arguments(0); $page = $event->object; $template = $page->template; $options['prependFiles'] = [ "{$template}.routes.php", "_init.php", ]; $options['appendFiles'] = [ "layouts/_main.php", ]; $event->setArgument(0, $options); }); // site/templates/_init.php $view = new \stdClass(); $this->wire('v', $view, true); // site/templates/someteplate.php bd($v) ---> null bd(wire('v')); ---> stdClass So I'm confused why I can't directly access API variable through $v variable in this case but able through wire('v')? But if I move code from "site/templates/_init.php" to "site/init.php" it is accessible through $v in templates files. Is it normal behavior?
-
HI @lickny2001 Try to use "insertAfter" method https://processwire.com/api/ref/wire-array/insert-after/
-
Hi @Juri Try to play with $config->sessionFingerprint $config->sessionFingerprint = 2;
-
Very often I have the same page name and title for all languages in ML context for some pages. So I create the page and only set title for default language (My title field is set to "Inherit from default language when blank, so it is ok to leave it blank). Then if you look at "Settings" tab you will see that name filed for non-default language is also filled with the value of default language. UI tells that I have names for this page in both languages, but in the DB you will see the next: Another way to get the same thing is to create a page with filled titles for both languages, save it, go to "Settings" tab and clear name field for non-default language and then save the page. UI will tell that you have page names for both languages, but in DB there will be the same picture as in the first example. Even if you manually enter the same name as in default language it will not get saved in DB. This behavior doesn't look intuitive for me and raises some issues. For example, this code will not work for these pages if(input()->urlSegment2) throw new Wire404Exception(); if(input()->urlSegment1) { $pagename = input()->urlSegment(1); $language = user('language'); $nameFieldSelector = $language->isDefault() ? "name" : "name" . $language; bd($nameFieldSelector); $match = pages()->findOne("template=blog-category|blog-item, $nameFieldSelector={$pagename}"); bd($match); if(!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } And this also will return a blank line. $language = $user->language; $pageName = $page->localName($language); // "" Of course there are workarounds for these particular cases but the current behavior of ML name field makes it not clear in some situation do I have a name for language or I don't. What do you think about it? How it possible to improve UI part? Should I raise issue for it?
-
Hi @dragan First of all thank you for your help @adrian @dragan I was wrong about localPath and localName. They are hookable. The problem was that I never called them in my templates, so didn't get any changes. $pages->addHookAfter("Page(template=projects-category|project)::localUrl", function (HookEvent $e) {; $page = $e->object; $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $pageName = $page->localName($language); if ($page->matches("has_parent=projects")) { $e->return = $langSegment . "projects/$pageName/"; } elseif ($page->matches("has_parent=products")) { $e->return = $langSegment . "products/$pageName/"; } }); Hook to Page::path also works. The issue was in my "matches" selector ))))) $pages->addHookAfter("Page(template=projects-category|project)::path", function (HookEvent $e) { $page = $e->object; $pages = wire('pages'); $user = wire('user'); $language = $user->language; $langSegment = $pages->get("/")->localPath($language); $pageName = $page->localName($language); if ($page->matches("has_parent=projects")) { $e->return = $langSegment . "projects/$pageName/"; } elseif ($page->matches("has_parent=products")) { $e->return = $langSegment . "products/$pageName/"; }; }, array('priority'=>101));
-
Hi @adrian. Thanks for your help. Are Page:localPath, Page::localUrl hookable? I tried hook after Page::localPath, but it does nothing.
-
Hi. I'm working on ML site and trying to hooks page url/path. Here the code that I'm using: $pages->addHookAfter("Page(template=projects-category|project)::path", function (HookEvent $e) { $page = $e->object; if ($page->matches("has_parent=/projects/")) { $e->return = "/projects/$page->name/"; } elseif ($page->matches("has_parent=/products/")) { $e->return = "/products/$page->name/"; } }); Nothing fancy and it works when default language is active. But when I switch to non-default langauge I get default page url. As far as I see the issue is relative to other Page::path hook in LanguageSupportPageNames.module. I was trying to prioritize hook by passing array('priority'=>2000) as last argument, but it doesn't sole the issue. Any thoughts?
-
[SOLVED] $pages->get("selector") only returns one page
Zeka replied to Hurme's topic in Getting Started
Hi @Hurme $pages->get() returns Page or Null https://processwire.com/api/ref/pages/get/ I guess that what are you looking for is $pages->find() https://processwire.com/api/ref/pages/find/ -
@Macrura Just made pull request with some modifications to support ML and useLanguages. It's quite dirty, but works for me. Maybe you will find it useful.
-
@adrian Does TD work in init method of autoload module? I'm trying to use bd(), but get Call to undefined function
-
@Macrura Yes, I have tested it and only values for default language are saved. As far as I can see the issue is in the processForm method.