Jump to content

Front-End Edit Lightbox (FEEL) for ProcessWire


tpr

Recommended Posts

20 hours ago, tpr said:

I'm not sure if it is but possibly yes. Try passing it inside the "overrides" array:

Works like a charm ? Thanks!

But i think the "selectorsToHideSuperUser" function don't work properly.

My user has the superuser role, but the tabs are only hidden if I use the option "selectorsToHide", the "selectorsToHideSuperUser" values are ignored.

<?php
// Settings/Delete Tab is VISIBLE with Superuser rights
echo $mycalc->feel(array("text" => "<i class=\"fas fa-edit\"></i>","overrides" => array("selectorsToHideSuperUser" => "#_ProcessPageEditDelete, #ProcessPageEditDelete, #_ProcessPageEditSettings, #ProcessPageEditSettings")));

// Settings/Delete Tab is INVISIBLE with Superuser rights
echo $mycalc->feel(array("text" => "<i class=\"fas fa-edit\"></i>","overrides" => array("selectorsToHide" => "#_ProcessPageEditDelete, #ProcessPageEditDelete, #_ProcessPageEditSettings, #ProcessPageEditSettings")));

 

Link to comment
Share on other sites

  • 8 months later...

I'm trying to access the feel module from within a custom module but it's throwing a 500 error with "Call to a member function feel() on null " in my module . I'm using $this->page->feel() in my module. Have no idea what is wrong with this? Can't figure out how to get a reference to feel inside the module.

Link to comment
Share on other sites

  • 8 months later...

Hello,

I am still using this module a lot on my site but I would like to avoid the reloadign of the page. Is this possible ?

Let me explain : I use edit links as follow :

	foreach($concernedPages as $p) {
	echo $p->title.' '.$p->feel(array("text"=>"[Edit]", "fields"=>title,image,summary,level"));
	}
	

So as you may imagine, I have a list of pages titles accompanied by an 'Edit' link. When I click this edit link, a lightbox opens up and I can edit the page.and this works fine BUT, when I hit the 'save' button, my lightbox closes and I wish the current page (which is not the page I have just fronend edited) would NOT reload as well.

Would there be a way to test if the current page is the edited one and reload if true, but prevent reloading if false ? Or simpler, just manually set reloading to false when we want it, resulting in the following code :

	echo $page->feel(); // THIS WOULD RELOAD CURRENT PAGE AFTER EDITING
	foreach($concernedPages as $p) {
	echo $p->title.' '.$p->feel(array("text"=>"[Edit]", "fields"=>title,image,summary,level"), 'reload'=>false); // THIS WOULD PREVENT RELOADING (NOTE THE EXTRA PARAMETER ADDED TO ILLUSTRATE MY POINT
	}
	

Thanks for helping !

PS : I hesitated on creating a new post but eventually decided on following this thread (I have read the complete thread but couldn't finc anything concerning my question)

EDIT : Eventually, I guess I've found it myself (and it wasn't so hard) adding this in my main JS file :

	var FEEL = {
    onBeforeReload: function (o) {
                return false;
    }
};
	

Edited by celfred
Answer found :
Link to comment
Share on other sites

  • 7 months later...

Hi everyone, I'm hoping someone can help here...

I've installed FEEL an added the following link in the template:

$editArray = array(
      "class" => "btn btn-primary",
      "text" => "Edit This Listing <i class='fa fa-pencil' aria-hidden='true'></i>",
      "fields" => "title,colour,listing_type,vendor,product_type,price,price_original,bin_link,product_has_packing,product_has_manual,product_has_leads,body,page_image,product_image_1,product_image_2,product_image_3"
);

echo $page->feel($editArray);

When a SuperUser tried to edit or create a page then the system works as it should.

However, when a non Super User tries the expected edit button appears and, when clicked, opens the Lightbox. However, at that point there are no fields presented, instead the  blue spinner icon appears for a few seconds then the box closes and the page reloads with no page fields presented.

PW version 3.0.165
FEEL version 1.4.0

UPDATE

Digging into FrontEndLightbox.js it seems the mode is set to 'page-edit' but editForm.length == 0. Looking at the comment in the file this means that:
 

Quote

in ProcessPageEdit, but the beforeHook on ProcessPageEdit::processSaveRedirect
fired and prevented the redirect to itself, making the response empty

In summary the user is logged, has edit and create permissions for the template in question but FEEL won't let them edit.

Anyone see a similar issue or can point me in the right direction?? @tpr

All help really appreciated!

Link to comment
Share on other sites

54 minutes ago, matjazp said:

I think tpr is not following this forum anymore and I forgot why we have this check... Try commenting the hook in .module file or adjust .js

Thanks for getting back to me @matjazp. That's a shame it's no longer supported. 

I tried your suggestion of commenting out the check lines in the the .module file and go straight to the line:
 

 var editForm = iframeContent.find('form#' + (mode === 'template-edit' ? 'ProcessTemplateEdit' : 'ProcessPageEdit'));

But sadly that made no difference.

In the .js file it seems to come down to this bit of code failing:

if (editForm.length) {
    if (mode !== 'template-edit') mode = 'page-edit';
    processPageEdit = true;
} else {
    editForm = iframeContent.find('form#ProcessPageAdd');
    if (editForm.length) {
        mode = 'page-add';
        processPageAdd = true;
    } else {
        // close the modal
        processSaveRedirect = true;
        setTimeout(function () {
            $.magnificPopup.instance.close();
        }, 100);
        return false;
    }
}

logging editForm.length shows a val of 0. So, the process arrives at this check but has no content to work with.

Link to comment
Share on other sites

Then you'll have to debug the javascript and figure why there is no form. Use Chrome dev tools and set a breakpoint at line 185, and examine iframeContent and editForm. FEEL is looking for a form element with the name of ProcessPageEdit or ProcessTemplateEdit. If there is no form or no iframeContent, the modal won't load. I just tried on latest PW dev and FEEL works, iframeContent.length is 1 and editForm.length is 1. 

Link to comment
Share on other sites

10 hours ago, MarkE said:

Hi @prestoav. I don't know if it is of any help, but I did a little module called AdminInModal which had similar aims to FEEL (which didn't do what I wanted). If it isn't quite right it may be simpler to modify than FEEL. You can grab it here.

Thank you @MarkE, I'll definitely take a look!

Link to comment
Share on other sites

6 hours ago, matjazp said:

Then you'll have to debug the javascript and figure why there is no form. Use Chrome dev tools and set a breakpoint at line 185, and examine iframeContent and editForm. FEEL is looking for a form element with the name of ProcessPageEdit or ProcessTemplateEdit. If there is no form or no iframeContent, the modal won't load. I just tried on latest PW dev and FEEL works, iframeContent.length is 1 and editForm.length is 1. 

Hi @matjazp I'll do that as I'm really curious to see what's going on. It makes no sense that it works for the super user but not other user roles, even when they apparantly have the same permissions for page edit and creation.

Link to comment
Share on other sites

The more I look at this the more I suspect a permissions issue. It works perfectly for the Super User, just not for any other role.

Checking the permissions for the 'editor' user like this, just before the call to FEEL to create the edit button:

$perms = $user->getPermissions();
foreach ($perms as $perm) {echo $perm->title . " | ";}
if ($page->editable()) {echo "Page is editable.";}

I get this:

"View pages | Edit pages | Delete pages | User can update profile/password | Page is editable."

Every piece of evidence is suggesting it should work for the user but it just doesn't unless the user is a super user. ?

Link to comment
Share on other sites

Can you comment $(adminIframe).css('visibility', 'hidden'); so that popup is visible immediately, maybe there will be some clue? Any JavaScript errors in the console? Can you test on some other page, perhaps with just title field and with default options?

Link to comment
Share on other sites

10 minutes ago, matjazp said:

Can you comment $(adminIframe).css('visibility', 'hidden'); so that popup is visible immediately, maybe there will be some clue? Any JavaScript errors in the console? Can you test on some other page, perhaps with just title field and with default options?

Hi @matjazp,

Thank you for your help, I'm not sure I would have tracked this down without that last suggestion to comment our the hidden visibility.

Long story short it was my own fault!

I built this site a long time ago and, in my naivety back then, added a protection line at the beginning of the main admin.php template that redirected front end users if they were to ever stumble on a real admin page using Fredi (the previous FE editor I was using). That line was redirecting front end users as soon as FEEL was trying to open an admin page. Oddly that wasn't happening with Fredi!?!

Anyway, it's now working as expected and it was my fault not the module!

Thanks again!

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
17 minutes ago, Flashmaster82 said:

Has anyone any clue how to enable the (Edit) button for non Superusers? I really need to solve this.. please help!!

If a user has the permission to edit the page, the edit link is also displayed.
You should check the permissions first 😉 

I use the module myself with users who do not have superuser rights.

  • Like 1
Link to comment
Share on other sites

@zoeck thanks for the fast reply. I have really tried everything.. permissions etc.. can´t get it to work.. also i have tried to modify the module file but no luck.

<?=$page->feel();?>

This is how i outfut the button from the module.

Have you also changed the guest role? Do you have a screenshot with your settings?

The page is an user page renamed "member" with template name "member" that i have cloned and the parent is Home/Members/ and also listed in the users page.

https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users

Link to comment
Share on other sites

2 hours ago, Flashmaster82 said:

Have you also changed the guest role? Do you have a screenshot with your settings?

What exactly are you planning to do with it?

I have only assigned a role (with edit right) to the appropriate users. 
I do not understand the question about guests

Link to comment
Share on other sites

@zoeck

My main goal is to have users, register > log in to their account > edit their own profile page > add children.

so based on this post
https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users

i clone the user template and renamed it member. So now i can create a new user with another template and also change parent. And also the user now have a page under home/members/.

The subpage under the "newuser" > newsubpage shows the edit button but not newuser.

image.thumb.png.a790052b124884f5dbadcce8801da431.png

Link to comment
Share on other sites

7 minutes ago, Flashmaster82 said:

Ok thanks i will have a look. But the problem is that the edit button don´t show up..

The individual user first needs the rights to edit, you can solve this via the Admin Restrict Branch module.
Then FEEL should also work correctly

Link to comment
Share on other sites

@zoeck

Quote

The individual user first needs the rights to edit

Yes but the module only let you restrict branches not give rights to edit pages. The problem is that the Edit button not showing up.. Maybe its because its a user-page and not a regular one. I don´t know how to solve this..

I have this code in my config.php

$config->userTemplateIDs = array(3, 53);
$config->usersPageIDs = array(29, 1047);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...