C5-8.4* Uncaught ReferenceError: PNotify is not defined

Permalink
I show a PNotify tooltip on mouseover element:
$(document).ready(function(){
    $('.element1').on('mouseover', '.element2', function(e) {
        var tooltip = new PNotify({
            text: pin_text,
            ...

It works fine on a local PC. But on hosting server the tooltip does not pop up and throws an error: "Uncaught ReferenceError: PNotify is not defined" unless I'm logged in. As soon as I login, it starts working without error.

What's wrong with what here?

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
Another thought - could it be that PNotify in C5 is only available to logged in users?

That'd make sense as it worked at home when I was always logged in.

What Asset does PNotify live in?
linuxoid replied on at Permalink Reply
linuxoid
I tried changing
var tooltip = new PNotify({

to
tooltip = ConcreteAlert.notify({

Now it says "Uncaught ReferenceError: ConcreteAlert is not defined".

If I use the following in the controller:
$al = \Concrete\Core\Asset\AssetList::getInstance();
$al->register('javascript', 'pnotify', 'js/build/vendor/pnotify/pnotify.js');
$this->requireAsset('javascript', 'pnotify');

it screws all my css design and simply appends the hints at the bottom of the page.
mnakalay replied on at Permalink Reply
mnakalay
You are not saying if that last attempt at least loads pNotify or not.

If you look through the core you will find the file concrete\js\build\core\app\alert.js in which pNotify options, as well as ConcreteAlert, are declared so you might want to use that as well.

And last you need styling which is provided by concrete\css\build\vendor\pnotify\pnotify.less

It's all there in the core. All it took to find out was to open concrete in an editor and do a quick search for "pNotify" and a little speculative thinking (if that's even a thing)
linuxoid replied on at Permalink Reply
linuxoid
I appreciate your comments very much. Thank you for the pointers.

I wasn't sure if the above was the right way of doing things. And even that was not enough to make it work properly. I could have simply added my own version of PNotify after all. But I thought there should be a much easier and better way of doing this thing.

However, knowing the state of C5 documentation, those who are not involved in the core development find it very hard if not impossible to figure out how stuff works in C5.

What does "open concrete in an editor mean?"
mnakalay replied on at Permalink Reply
mnakalay
If you were simply an end user I'd say you're right. But you're a developer and already have add-ons in the marketplace so I have to disagree with you.

When I discovered C5 I knew HTML, CSS, and a bit of JS.

I started from scratch. Until then I had tried several times to understand PHP and couldn't. I know, it's supposed to be an easy language but, at the time, I just didn't get it.

I started to understand it thanks to C5. At the time it was the legacy MVC architecture.

I just started digging into it, downloaded free plugins and studied them. I also was lucky Remo had written a great book that really helped.

When they switched to the new version I was crushed. I had no idea what namespacing was, all those new concepts totally eluded me. To be honest, I still have to think hard sometimes to remember Attributes vocabulary, what's a key, a category... That's how slow I can be sometimes.

And all that time I asked exactly 2 questions on the forum. I benefited a lot from answers other people got to their questions but I only asked 2 questions.

And never got an answer.

But here I am, I have plugins in the marketplace, I participated code to the core, I'm an admin in the PRB and sometimes, people that I see as my superior in code ask me questions...

I am far from being an exceptional coder but I think what helped me most was my curiosity and my relentless need to "figure it out"

So you see, you can blame it on people not answering you or the lack of documentation or say others have it easier because they are core contributors... But in the end, it's really all up to you. Even core contributors had to start somewhere.

One last tip: C5 is now built on top of tools that are really really well documented (Laravel, Doctrine, Symfony...) Have you thought of looking into those?

I know you didn't ask for a lecture so feel free to ignore all this. I just thought I'd share though.
mnakalay replied on at Permalink Reply
mnakalay
"open concrete in an editor" means to open the concrete folder in whatever code editor you use to do your work (Sublime Text, Visual Studio...) so you can go through and study the code, understand the structure, stuff like that.
linuxoid replied on at Permalink Reply
linuxoid
I just couldn't get the PNotify to work. So I scrapped it and use Bootstrap Tooltip instead - same functionality but without problems PNotify has