Personalize conflict with notify

I’ve looked at the code and I can’t see any way Notify could interfere with Personalize.

I’ll try to find time to test the two together. I assume that you’re now running MODX 2.8.4. Let me know if that’s not the case.

Something else you might try in the meantime is to uninstall and remove All versions of Personalize in Package Manager, then download and install it again.

I tried Personalize with and without @CODE: and it worked perfectly for logged-in and not-logged-in users.

Then I tried it with your specific code, and it produced nothing.

Once I put backticks around the values of the &yesChunk and &noChunk values, it worked as it should. :wink:

please check my results step by step: notiffy-personalize_issue.pdf - Google Drive

Also the code( as you can see i also use backticks around the valusesof yes/no chunk:
main page:

<!doctype html>
<html lang="en">
<head>
  
        
Full name=[[!GetFullname]] 

<div class="container">
    <div >
 <div class="row">
                <div class="col-md-12 border border-light mb-0">
                    <div class="bg-default border-0 sticky-top float-right">
                        [[!Personalize?
                            &ph=`personalize.name`
                            &fullName=`1`
                            &yesChunk=`@CODE:
                                <a href="[[~45]]" title="" class="fas fa-user-circle text-success font-size-sm  mr-3">
                                     [[!GetFullname]] 
                                </a>
                                <a href="[[~12? &action=logout]]" title="LogOut" class="fas fa-sign-out-alt text-success font-size-sm  mr-3">
                                    Logout </a>`
                            &noChunk=`@CODE:
                                <a href="[[~12]]" title="Login" class="fas fa-user-circle text-warning font-size-sm  mr-3">
                                    Login
                                </a>
                                <a href="[[~43]]" title="Registration" class="fas fa-sign-in-alt text-warning font-size-sm ml-2">
                                    Registration
                                </a>`
                        ]]
                    </div>
                </div>
            </div>
    </div>
</body>
</html>

Resources–>Login:

<div class="container">
    <div class="row">
        
        <div class="col-md-12 back-color">
            [[!Login? &loginTpl=`tpl_login` &actionKey=`action` &loginKey=`login` &redirectToPrior=`1` &logoutResourceId=`1`]]
        </div>
        <div class="col-md-1"></div>
    </div>
    
</div>

Chunks—>tpl_login:


    <div >
        <form method="post" action="[[~[[*id]]]]" class="w-50 mt-4" style="display:table; margin:auto;">
                <div class="form-group text-success">
                    <label for="authLogin">Login</label>
                    <input type="email" name="username" class="form-control" id="authLogin" required>
                   
                </div>
                <div class="form-group text-success">
                    <label for="authPass">Password</label>
                    <input type="password" name="password" class="form-control" id="authPass" required>
                </div>
                <div class="form-group">
                    <div class="row">
                        <div class="col-md-6 "><small class="form-text text-success"><a href="[[~44]]" class="text-success">Forgot Password</a></small></div>
                        <div class="col-md-6 text-right"><small class="form-text text-success"><a href="[[~43]]" class="text-success">Registration</a></small></div>
                    </div>
                </div>  
                <hr class="my-4">
                <div class="form-group">
                    <input type="hidden" name="action" value="login">
                    <button type="submit" class="btn btn-success float-right mb-2">Login</button>
                </div>
        </form>
        [[!+errors]]
    </div>

I can’t reproduce your problem.


Also the Personalize snippet is very simple.

It’s basically this line ($modx->user->hasSessionContext($modx->context->get('key'))) to test if the current user is authenticated.

If you create a snippet with this code, does that work?

if ($modx->user->hasSessionContext($modx->context->get('key'))){
    return 'User is logged in.';
} else {
    return 'User is NOT logged in!';
}

Instead of installing and uninstalling the Notify extra.
Can you reproduce the same behavior when you just activate/deactivate the plugin with the name “Notify” (There is a checkbox “ Inactive plugin”)?

Hello, thank you for your response.

  1. I created the snippet you suggest and it works
  2. I tried also your suggestion with inactive plugin checkbox but does not change nothing. The problem still exist when i deactivate the plugin.

To me it seems that when notify is installed for some reason is not changing from &no Chunk to &yes Chunk. I tried also this:

[[!Personalize?
         &yesChunk=`@CODE:<a href="[[~12? &action=logout]]">Logout </a>`
         &no Chunk=`@CODE:<a href="[[~12]]">Login</a>`
         &ph=`personalize.name`
         &fullName=`1`                             
                     ]]

and the problem is exactly the same.
The fact that you cannot reproduce the issue, from the moment that i reproduced id immediately by the new-fresh modx installation means that something is wrong with my code. (Did you tried to reproduced the issue using exactly my code?)

sorry correction:

 [[!Personalize?
                            &ph=`personalize.name`
                            &fullName=`1`
                            &yesChunk=`@CODE:<a href="[[~12? &action=logout]]" >Logout </a>`
                            &noChunk=`@CODE:<a href="[[~12]]">Login </a>`
                        ]]

Yes, and the issue is not reproducible.


If you create a new snippet (name it for example “myPersonalize”), copy the code from the snippet “Personalize” and then use this new snippet [[!MyPersonalize? ... ]] instead, does that work?

I already tested this and no difference.

Maybe just try using a custom snippet instead.

Move the @CODE parts into separate chunks (“myYesChunk” and “myNoChunk”) and use a custom snippet with code like this:

<?php
if ($modx->user->hasSessionContext($modx->context->get('key'))){
    $profile = $modx->user->getOne('Profile');
    if ($profile){
        $name = trim($profile->get('fullname'));
        $modx->setPlaceholder('personalize.name', $name);
    }
    
    return $modx->getChunk('myYesChunk');
} else {
    return $modx->getChunk('myNoChunk');
}

Oh yes this is a solution. Thank you very much.
Of course it could be good to find out what causes the previous behavior.
Any way at least the job is done.
Thank you all

I agree, but as I can’t reproduce the issue, I can not debug it.
It’s really weird, that the custom snippet works as it does more or less the same as “Personalize”. I also don’t see how “Notify” could influence this code.

The most weird for me is that everything it works normal without notify installation

I could not reproduce it either, and I do have Notify installed.

In the default properties of the Personalize snippet, are any of them set other than &firstName and &fullName?

Do you have a Notify snippet tag on the page or in the page template?

The only other thing I can think of is that both extras have an &allowedGroups property.

It shouldn’t interfere, since the Notify snippet should only execute when you click on “Launch Notify” unless there’s a snippet tag for Notify somehow being parsed on the page where you’re using Personalize.