Jump to content

LAPS

Members
  • Posts

    258
  • Joined

  • Last visited

Posts posted by LAPS

  1. Hi @adrian, thanks for the support.

    1. I (and I think almost any developer) am a bit reluctant to change the source code directly. It should work as-it-is.
    2. The enablement of the "Rename on Save" option helps with LoginRegisterPro (LRP). However, I find it a bit negative for performance reasons in addition to breaking file links.

    Can we expect in a future release of the module to allow selecting the user template and renaming LRP profile image just on upload?

  2. @Andy my problem is not related to check if the users have or not have the profile image set but to publicly display their image file. Because the user pages are located under PW Admin > Access > Users, (normally) their profile image is not accessible to the public, and I would like to make those images publicly visible the right way.

    BTW I'm using LoginRegisterPro features to allow users to edit their profile image.

  3. I would like to publicly display image files of users e.g. a profile picture on the front end and I've searched the forum without much success to find a satisfactory solution for my case, probably the most common one.

    The problem in displaying user images is that the user pages are located under PW Admin > Access > Users, which prevent image files to be loaded on the front end from the related access-restricted assets/files folder.

    In my case, I've the profile_picture Image field in the user template and I cannot move the user pages outside PW Admin > Access > Users.

    How did you solve this?

     

    P.S.: I'm sure this is a common case for many PW developers and can be useful for PW newcomers, and I hope answers to this topic will be so good to many people that, perhaps, I'll need to change the title of this topic to something like "How to display user images on the front end (The Ultimate Guide)".

  4. Hi @adrian, I would like to use this module for auto-renaming the profile image of users when using the LoginRegisterPro module. Two things:

    1. In the module settings, the "Enabled Templates" option hasn't the user template as a selectable option. Note: in my case I think selecting by template is better than selecting by pages ("Enabled Pages" option) because I've users under multiple parents.
    2. The module seems do not work for the LoginRegisterPro profile action/form.

    Any help?

     

  5. @adrian, thank for pointing me out to a possible solution.

    I'm trying SwiftDefaultApps and added the 'netbeans' URI Scheme to it. Now, when I click on the link in the Tracy panel the NetBeans app opens but the file (and the line) doesn't open.

    In Tracy Debugger module settings, I tried to set 'Editor protocol handler' as follows:

    netbeans://open?file=%file&line=%line
    netbeans://open/?url=file://%file&line=%line
    netbeans://file/%file:%line

    ... and some more, without success.

  6. @adrian I tried to set

    Editor protocol handler:
    netbeans://open?file=%file&line=%line
    Local root path:
    /Users/<MyMacOSUserName>/NetBeansProjects/<MyProjectFolder>/

    That in the Tracy panel outputs the link (which seems to be correct) as follows:
    netbeans://open?file=/Users/<MyMacOSUserName>/NetBeansProjects/<MyProjectFolder>/site/templates/template-name.php&line=139

    But when I click on the link in the Tracy panel, NetBeans doesn't open and in the browser console I get the error message:
    Failed to launch 'netbeans://open?file=netbeans://open?file=/Users/<MyMacOSUserName>/NetBeansProjects/<MyProjectFolder>/site/templates/template-name.php&line=139' because the scheme does not have a registered handler.

    There is no guide about NetBeans for Mac. Probably NetBeans and/or Mac aren't configured well.  

    😕

  7. In module settings of Tracy Debugger there is the field "Editor protocol handler" where you can set the Tracy Debugger::$editor variable:

    154373425_Screenshot2023-01-22at14_26_55.thumb.png.51388a43cf72c66287e52ecd46fb857a.png

    I done some research to set it for NetBeans, without success.

    What is the editor protocol handler for NetBeans (if any) and how to set it in Tracy Debugger module settings?

     

    I'm using Apache NetBeans 16 running on Mac OS Ventura 13.0.
    Folder of NetBeans is /Applications/NetBeans/Apache NetBeans 16.app
    Folder of my project files is /Users/<MyMacOSUserName>/NetBeansProjects/<MyProjectFolder>

  8. Hi, in a template file I successfully used $files->include():

    File: /site/templates/a-template-file.php

    <?php namespace ProcessWire;
    $files->include('partials/file-name.php');
    // ...

    This loads the /site/templates/partials/file-name.php file containing other ("nested") $files->include() statements, for instance:

    File: /site/templates/partials/file-name.php

    <?php namespace ProcessWire;
    $files->include('partials/other-file-name.php')
    // ...

     

    Now, in the template file, I would like to use $files->render() (instead of $files->include()) to retrieve output as a return value:

    File: /site/templates/a-template-file.php

    <?php namespace ProcessWire;
    $output = $files->render('partials/file-name.php');
    // ...

    But, by using the render() (instead of the include()) function, I get the error message coming from within the rendered /site/templates/partials/file-name.php file:

    Quote

    Error: Exception: ___include: File does not exist: ./partials/other-file-name.php
    In /wire/core/WireFileTools.php line 1947

    I think the problem is the "./" as shown in the above error message.

    Note: In the rendered /site/templates/partials/file-name.php file, I tried to use the "nested" $files->include() with the allowedPaths option set (i.e. $files->include('partials/other-file-name.php', [], ['allowedPaths' => [$config->urls->templates]])) and many other things, without success.

     

    How can I solve the problem in order to use the render() (instead of the include()) function?

  9. 1 hour ago, zoeck said:

    You are probably missing the processwire namespace in the php file 😉

    I tried to state the namespace ProcessWire at the top of the Hanna code without success. I've to state the inline \ProcessWire\ namespace to make it work. 🤷🏻‍♂️

    It would be great if someone explains why this happens. 😃

  10. Hi, in the /site/init.php file I've stated:

    wireSetting([
      'a_key' => [
        'value1', 'value2', 'valueN'
      ],
      '...' => '...'
    ])

    I normally use with success the wireSetting in my template files like this: wireSetting('a_key').

    I would like to use this wireSetting in an Hanna code, but when I do this I get the error "Method ProcessWire::wireSetting does not exist or is not callable in this context".

    How can I use wireSetting in Hanna code?

     

  11. The problem here is that I've set up various Hanna code tags and, since I'm going to create many new ones increasing their number, the list of code tags in the PW admin backend (Admin > Setup > Hanna Code) will be a mess e.g. it'll be hard to find one Hanna code among the many created ones.

    A solution to this problem could be to name Hanna code tags with a criterion, but what is a good practice for naming them?

    How do you keep organized/ordered your Hanna code tags in the PW admin backend?

    • Like 1
  12. On 1/11/2023 at 3:26 AM, adrian said:

    Thanks for the report @LAPS - it should be fixed in the latest version. Please let me know.

    @adrian, thanks for updating the module to v0.1.8, which I installed in ProcessWire 3.0.210.

    I'm using Hanna Code v0.3.2 and Hanna Code Text Formatter v0.3.2 (the latter with module settings Open Tag set to [[ and Close Tag set to ]]).

    Given in the field description and/or notes I use a hanna code such as [[my-hanna-code-tag attribute1="Some value" attribute2="Some other value"]], when I access the PW Admin > Edit Page (page where that field is used) then I get the error: "Unknown Selector operator: '[empty]' -- was your selector value properly escaped? In /wire/core/Selectors.php line 222".

    1553267305_Screenshot2023-01-15at00_02_44.thumb.png.4503939a6a5606f8ff3b077872c120ff.png

    😳

    Note: the error doesn't occur when using hanna code such as [[my-hanna-code-tag]].

  13. Hi @adrian,
    maybe I've a problem some way related to the one of @xportde.

    I just installed DynamicDescriptionNotes 0.1.6 in ProcessWire 3.0.200.

    In DDN module settings I tried both options: "Allow HTML" checked and unchecked.

    If "Allow HTML" is unchecked then Markdown is "translated to HTML" but output is raw HTML.

    1729715649_Screenshot2023-01-02at05_30_57.thumb.png.ded77464b1f31232eac794b04cdf4a7c.png

    If "Allow HTML" is checked then Markdown output is raw.

    793046769_Screenshot2023-01-02at05_32_08.thumb.png.3645b03fbee2ff7981f55382797027b6.png

    I set "Notes" and "Description" (field settings in template context) as follows:

    Some **Markdown** text `code` [link](/path/to/a/page/).
    - [page.parent.url]
    - [page.title]
    - Test link to [Edit Parent](./?id=[page.parent.id])


     

    What could be the problem?

    • Like 1
  14. By using ['noHooks' => true] I still run into trouble.. and the hook runs between 3-8000+ times (var_dump, log, etc.)!

    wire()->addHookAfter("User::changed(user_bookmarks)", function(HookEvent $event) {
      // ...
      // here something that handles the following hook creation or updating and that avoids running into infinite loop
      // ...
      wire()->addHookAfter("Pages::savedPageOrField($user)", function(HookEvent $event) use($user, $old, $new) {
        // here something that save $user
        // $user->save() or $user->setAndSave() with $options ['noHooks' => true]
         
        // ...
        $event->removeHook(null);

     

    19 hours ago, Jan Romero said:

    You can also hook savedPageOrField(), in which case the names of the changed fields will be in $event->arguments(1).

    Do you mean to use the savedPageOrField() hook "standalone"? Or "nested" within another hook as in the above code?

  15. @Jan Romero I used your code and some other weird functions to come up with a solution, without success.

    2 hours ago, Jan Romero said:
    wire()->addHookAfter("Pages::savePageOrFieldReady(template=user)", function(HookEvent $event) {
        $user = $event->arguments(0);
    
    	if (!$user->isChanged('user_bookmarks'))
    		return; //bookmarks weren’t changed, nothing to do
    
    	$user->of(false);
    	$user->set('title', 'that user who keeps changing their bookmarks');
    });

    It seems ignoring all-known-to-me $user->set('title', '...')-like functions for saving the user. User changes (except user_bookmarks) are not saved after the process ends.

  16. @Jan Romero I was too fast to say that worked for me. The log files seem gone crazy receiving many entries! ? ?

    Probably, it's because within the Pages::savedPageOrField($user) hook function I'm updating other $user fields, which causes the infinite loop. In fact, if I don't update the $user within savedPageOrField($user), the whole hook subtly works.

    I think the problem is related to the Pages::savedPageOrField($user) hook and I'm trying to limit the run of this hook by passing someway the second argument $changes...

    // usage with all arguments
    $pages->savedPageOrField(Page $page, array $changes = []);

    ... something like made in the official docs by using changed(0:order_status, 1:name=pending, 2:...)

    // ??? = what? how to state the $changes array?
    wire()->addHookAfter("Pages::savedPageOrField(0:$user, 1:???)", function(HookEvent $event) use($user, $old, $new) { ...

    and by setting limiting conditions the more classic way

    wire()->addHookAfter("User::changed(user_bookmarks)", function(HookEvent $event) {
      // ...
      wire()->addHookAfter("Pages::savedPageOrField($user)", function(HookEvent $event) use($user, $old, $new) {
        // if something, exit now
        ???
    
        // ...

    Any help is appreciated.

  17. Thanks @Jan Romero.

    I'm experimenting with the savedPageOrField hook to limit it to run for user pages (because I'm working on Users), and I report this:

    // ready.php
    wire()->addHookAfter("Pages::savedPageOrField", function($event)  { ... // does work
    wire()->addHookAfter("Page(template=user)::savedPageOrField", function($event)  { ... // does not work
    wire()->addHookAfter("Pages(template=user)::savedPageOrField", function($event)  { ... // does not work
    wire()->addHookAfter("User::savedPageOrField", function($event)  { ... // does not work
    wire()->addHookAfter("Users::savedPageOrField", function($event)  { ... // does not work
    
    // template.php // ...
    $user->setAndSave('user_bookmarks', $user_bookmarks);

    A say in the PW community is "users are pages too", so I expect hooks to work with Users as they work with Pages. Am I going to be victim of another of the classic blunders? ?

    Any help about achieving with hooks (even the savedPageOrField one) the goal to take custom actions each time the user's user_bookmarks field get updated?

×
×
  • Create New...