-
Posts
908 -
Joined
-
Last visited
-
Days Won
1
Posts posted by PWaddict
-
-
If I use the following hook, with 2 languages works fine but with 1 language I have to press the Save button twice for the title field to get updated:
$wire->addHookBefore('ProcessPageEdit::processInput', function(HookEvent $event) { $page = $event->object->getPage(); if($page->template == "mytemplate") { $page->title = $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date"); } });
?
-
5 minutes ago, clsource said:
https://processwire.com/api/ref/languages/get-default/
$wire->addHookBefore("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name != 'mytemplate') return; if(count(wire("languages")) > 1) { $defaultLang = wire("languages")->getDefault(); $page->title->setLanguageValue($defaultLang, "New Value"); } else { $page->title = "New value"; } $event->arguments(0, $page); });
That was I'm trying and it works but it doesn't work with only just 1 language when using fields to get the title value.
$wire->addHookBefore("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name != 'mytemplate') return; if(count(wire("languages")) > 1) { $defaultLang = wire("languages")->getDefault(); $page->title->setLanguageValue($defaultLang, $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date")); } else { $page->title = $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date"); } $event->arguments(0, $page); });
-
7 minutes ago, clsource said:
May be this can work?
https://processwire.com/api/ref/pages-type/save-ready/
$wire->addHookBefore("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name != 'mytemplate') return; $defaultLang = wire("languages")->get("default"); $page->title->setLanguageValue($defaultLang, "New Value"); $event->arguments(0, $page); });
Thanks, this seems to work if I have 2 languages but it doesn't work if I have only 1 and I don't understand why cause it's the default language for both cases. I need it to work with 1 or additional languages.
-
-
Still not working...
-
It doesn't work. The title field is still empty.
$wire->addHookAfter("Pages::saveReady", function(HookEvent $event) { if($page->template->name != 'mytemplate') return; $defaultLang = wire("languages")->get("default"); $page->title->setLanguageValue($defaultLang, "New Value"); });
-
How to manipulate page title on a hook after page save for ONLY the default language?
-
On localhost where it's working properly I'm having 3 languages. On live server I have only 1 language and after I delete the other 2 additional languages on localhost the problem now happens there too.
-
I'm using the following hook in site/ready.php to manipulate page title in admin section and it work fine in localhost but I just noticed that it doesn't work on live server. I'm always getting "Untitled" even though all 4 fields have values.
$wire->addHookAfter("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments[0]; if($page->template->name != 'mytemplate') return; if($page->myfield_text_a && $page->myfield_text_b && $page->myfield_options && $page->myfield_date) { $page->title = $page->myfield_text_a . ", " . $page->myfield_text_b . ", " . $page->myfield_options->title . ", " . $page->getFormatted("myfield_date"); } else { $page->title = "Untitled"; } });
How is this possible???
-
I'm getting hundreds of PHP notices and 1 warning when visiting sitemap.xml url with debug enabled. With debug disabled everything seems ok.
Using PW 3.0.165 and PHP 7.4.9.
Notice: Trying to access array offset on value of type null in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php on line 413 Notice: Trying to access array offset on value of type null in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php on line 417 Notice: Trying to access array offset on value of type null in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php on line 427 Notice: Trying to access array offset on value of type null in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php on line 353 Warning: Cannot modify header information - headers already sent by (output started at C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php:427) in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupSitemap\MarkupSitemap.module.php on line 192
-
Feel free to checkout my module https://github.com/PWaddict/TextformatterOptimizeExternalLinks where you can optimize all the external links.
- 1
-
30 minutes ago, sjaaksken said:
I can't seem to hide the scf-website field, what should I add to the CSS?
Use this:
#wrap_Inputfield_scf-website { display: none; }
-
@kongondo are you planning to add affiliate system?
-
@MaierGrem I have already posted in the module's forum, and problem solved by @adrian. Thanks anyway :)
Can a moderator please delete this topic, as it's useless. I didn't knew when created it that the issue was from a third-party module.
-
3 minutes ago, adrian said:
Maybe I could programmatically replace mtime with modified. Can you think of any reason why mtime would actually be needed vs modified?
modified: Unix timestamp of when Pagefile (file, description or tags) was last modified.
mtime: Unix timestamp of when file (only) was last modified.Taken from Pagefile API Reference.
-
9 hours ago, adrian said:
I noticed though that it all works fine if you use $file->modified instead. Would that work ok for your needs instead of mtime?
Thanks a lot. I switched from mtime to modified and the problem is gone :) Maybe you should add a note on the Rename rules to avoid using mtime.
-
3 minutes ago, adrian said:
Ok, I think I have narrowed it down - if you don't have "overwrite" checked and you use $file->mtime it doesn't know how to name the file at the correct point it needs to. Let me see if I can fix.
Yep, I'm getting the same results with you.
- 1
-
Hm, after I checked the "Overwrite existing files?" on image field the problem is gone. So, the module to properly work needs that option checked?
-
1 hour ago, adrian said:
I am curious what Tracy's PageFiles panel reports after the initial saving of the page.
Tracy displays them in orange color as orphans.
-
The structure on my template is in this order:
various fields
Image field
Repeater field
Repeater field
various fieldsThe image doesn't display on frontend because it seems that it doesn't get saved in database??? I'm checking if the image exists like this: if($page->image) etc. There is nothing wrong in the code on template cause if I save the page AGAIN then this time the image is properly getting saved and displayed on frontend.
Image Maximum files allowed: 1
Formatted value: AutomaticEDIT: It's a multi-language site.
-
Hello @adrian
Today I noticed a very strange behaviour with the module. If I upload an image on the Image or CroppableImage3 field and then add a new repeater item on a repeater field and publish / save the page, the image doesn't display on front-end. The image and its variations are visible on back-end and on the related folder in assets.
If I first add a new repeater item on a repeater field and then upload an image on the Image or CroppableImage3 field then there is NO problem. WTF?
I verified that this is caused by the module cause when I temporarily disable the rule there was NO problem. My rule is: {$page->title}_{$file->mtime} with Rename on Save checked.
I'm using PW 3.0.135.
-
Hello. Today I noticed a very strange behaviour. If I upload an image on the Image or CroppableImage3 field and then add a new repeater item on a repeater field and publish / save the page, the image doesn't display on front-end. The image and its variations are visible on back-end and on the related folder in assets.
If I first add a new repeater item on a repeater field and then upload an image on the Image or CroppableImage3 field then there is NO problem. WTF?
I'm using PW 3.0.135.
Can PLEASE someone help me?
EDIT: It seems the issue is caused by Custom Upload Names module. I will post on the related topic.
-
@Robin S It works. Thanks a lot!
- 1
-
3 hours ago, netcarver said:
@PWaddict You could try Robin's module - https://github.com/Toutouwai/LimitRepeater. I don't know if this could help though, it's just a thought.
LimitRepeater can't lock repeater items.
[SOLVED] How to manipulate page title for ONLY the default language?
in Multi-Language Support
Posted
Nobody knows the proper way to achieve it with just 1 language?