Jump to content

Fredi - friendly frontend editing


apeisa

Recommended Posts

Cannot reproduce that problem with settings. Which pw version you are using?

About adding pages: for the one page add, we would need to have template and parent as required (parent could use current page is not set) and then bunch of fields. That should work.

Link to comment
Share on other sites

ProcessWire 2.5.19 dev

Maybe I should test it with a new and clean PW install...

Adding pages sounds good. Parent and template could be set as param by code or an default like current page. With hidden tabs frontend create pages will be comfortable for all users.

Link to comment
Share on other sites

thanks for the update apeisa, installaton worked smoothly now.

one problem when having stacked edit-buttons:

post-2137-0-05939800-1432586938_thumb.pn

i have a widget with edit-button and all the blog-posts in a list inside this widget. so they display when hovering the widget and not only when hovering the list-item (i was hovering the first boxed blog-item in the screenshot)

.frediparent:hover > .frediwrapper > .fredi {display: block;}

that would solve it, but i don't know if that leads to problems anywhere else in your module?

Link to comment
Share on other sites

Thanks Bernhard, that should be safe change, just committed!

I also added simple support for adding new pages. Current syntax is this:
 

<?= $fredi->setText("Add new article")->addPage("article", "title|date|summary", $parent) ?>

First parameter is template (required), second is fields (optional, uses only title if empty) and third one is optional parent page (uses current page otherwise).

It doesn't do much, but works pretty nicely. It redirects to new page after successful save. Name is created from title.

  • Like 4
Link to comment
Share on other sites

  • Add page works fine without images / files. 
    TemplateFile: New page '/pw/gfh/my-page//' must be saved before files can be accessed from it<pre>#0 /volume1/web/pw/wire/core/PagefilesManager.php(253): PagefilesManager->___path() #1 /volume1/web/pw/wire/core/PagefilesManager.php(213): PagefilesManager->path() #2 /volume1/web/pw/wire/core/PagefilesManager.php(67): PagefilesManager->createPath() #3 /volume1/web/pw/wire/core/PagefilesManager.php(55): PagefilesManager->init(Object(Page)) #4 /volume1/web/pw/wire/core/Page.php(1781): PagefilesManager->__construct(Object(Page)) #5 /volume1/web/pw/wire/core/Pagefiles.php(74): Page->filesManager() #6 /volume1/web/pw/wire/core/Pagefiles.php(58): Pagefiles->setPage(Object(Page)) #7 /volume1/web/pw/wire/modules/Fieldtype/FieldtypeImage.module(33): Pagefiles->__construct(Object(Page)) #8 /volume1/web/pw/wire/core/Fieldtype.php(438): FieldtypeImage->getBlankValue(Object(Page), Object(Field)) #9 /volume1/web/pw/wire/core/Page.php(830): Fieldtype->getDefaultValue(Object(Page), Object(Field)) #10 /volume1/web/pw/wire/core/Page.php(693): Page->getFieldValue('image') #11 /volume1/web/pw/wire/modules/Fieldtype/FieldtypeFile.module(118): Page->get('image') #12 /volume1/web/pw/wire/core/Wire.php(387): FieldtypeFile->hookProcessInput(Object(HookEvent)) #13 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('processInput', Array) #14 /volume1/web/pw/wire/core/InputfieldWrapper.php(457): Wire->__call('processInput', Array) #15 /volume1/web/pw/wire/core/InputfieldWrapper.php(457): InputfieldImage->processInput(Object(WireInputData)) #16 /volume1/web/pw/wire/modules/Inputfield/InputfieldForm.module(76): InputfieldWrapper->___processInput(Object(WireInputData)) #17 [internal function]: InputfieldForm->___processInput(Object(WireInputData)) #18 /volume1/web/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #19 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('processInput', Array) #20 /volume1/web/pw/site/modules/Fredi/FrediProcess.module(109): Wire->__call('processInput', Array) #21 /volume1/web/pw/site/modules/Fredi/FrediProcess.module(109): InputfieldForm->processInput(Object(WireInputData)) #22 /volume1/web/pw/wire/core/ProcessController.php(213): FrediProcess->executeAdd() #23 [internal function]: ProcessController->___execute() #24 /volume1/web/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #25 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('execute', Array) #26 /volume1/web/pw/wire/core/admin.php(85): Wire->__call('execute', Array) #27 /volume1/web/pw/wire/core/admin.php(85): ProcessController->execute() #28 /volume1/web/pw/wire/modules/AdminTheme/AdminThemeDefault/controller.php(13): require('/volume1/web/pw...') #29 /volume1/web/pw/site/templates/admin.php(15): require('/volume1/web/pw...') #30 /volume1/web/pw/wire/core/TemplateFile.php(169): require('/volume1/web/pw...') #31 [internal function]: TemplateFile->___render() #32 /volume1/web/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #33 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('render', Array) #34 /volume1/web/pw/wire/modules/PageRender.module(356): Wire->__call('render', Array) #35 /volume1/web/pw/wire/modules/PageRender.module(356): TemplateFile->render() #36 [internal function]: PageRender->___renderPage(Object(HookEvent)) #37 /volume1/web/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #38 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('renderPage', Array) #39 /volume1/web/pw/wire/core/Wire.php(387): Wire->__call('renderPage', Array) #40 /volume1/web/pw/wire/core/Wire.php(387): PageRender->renderPage(Object(HookEvent)) #41 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('render', Array) #42 /volume1/web/pw/wire/modules/Process/ProcessPageView.module(172): Wire->__call('render', Array) #43 /volume1/web/pw/wire/modules/Process/ProcessPageView.module(172): Page->render() #44 [internal function]: ProcessPageView->___execute(true) #45 /volume1/web/pw/wire/core/Wire.php(365): call_user_func_array(Array, Array) #46 /volume1/web/pw/wire/core/Wire.php(320): Wire->runHooks('execute', Array) #47 /volume1/web/pw/index.php(240): Wire->__call('execute', Array) #48 /volume1/web/pw/index.php(240): ProcessPageView->execute(true) #49 {main}</pre>
    
     

    I know this problem and used a "storage page" to store files and move them after the page is saved / created.

  • Users can modify the form with a simple url change. 
    /admin/page/fredi-field-edit/add/?parent_id=1160&template=basic-page&[b]fields=title|body|image[/b]&modal=1
    
  • Is a sanitizer used to clean the user input?

    Maybe you could add an additional param array (field -> sanitizer)? If a sanitizer is given, it will be used to clean the input value.

Link to comment
Share on other sites

I'm using Fredi to allow other site admins to edit users. I have specified that the delete tab should be hidden but for some reason it still shows on the first user/page, but not on any others - I've deleted all users and started from scratch but the problem persists.

Maybe I'm not using the 'hide tabs' function in the correct place? This is from my template file:

echo $fredi->render('title|email|pass|allowed_screeners', $user); echo $fredi->hideTabs('delete');

This is echoed for each user with a specific role. Any ideas?

Also, in future I might want to give some admins visibility of the delete tab but currently, if I delete a user, the iframe refreshes and shows the entire page tree from the home page. Is it possible to make it have the same function as when a user saves the changes? ie. refresh the entire page/close the modal and show the changes on the page?

Hope that makes sense!

Thanks in advance.

Jonathan

I'm using 2.5.3

Edited by Jonathan
Link to comment
Share on other sites

Any ideas?

Solved the first problem of showing up on the first user. I moved the $freid->hideTabs function to the top of the page where I call in the fredi module. But, if I follow the instructions on the fredi module page and have 

echo $fredi->hideTabs

it echos 'fredi' on the page as text. Removing the echo fixes this.

Link to comment
Share on other sites

ProcessWire 2.5.19 dev

Maybe I should test it with a new and clean PW install...

Adding pages sounds good. Parent and template could be set as param by code or an default like current page. With hidden tabs frontend create pages will be comfortable for all users.

Did a clean PW install fix the issue?

I'm having same issue - If I hide settings tab, can't save any changes to the page. 

Link to comment
Share on other sites

<?php
if($user->hasRole("editor")){ echo ""; }
elseif(!$user->allowed_screeners->has($page)){ $session->redirect("/screening-room/"); }

include('./_header.php');

$fredi = $modules->get("Fredi");
echo $fredi->renderScript();
?>
			<!-- Main -->
				<section id="main" class="container">
					<section class="box special">
						<header class="major">

							<div> <?php include("./screener.php"); ?>
							<script src="http://jwpsrv.com/library/xxxxxxxxxxxxxx.js"></script>


							<div id="myElement">Loading the player...</div>
							<script type="text/javascript">
							jwplayer("myElement").setup({
							file: "rtmp://xxxxx.xxxxxxx.com/cfx/st/mp4:<?=$canned_policy_stream_name; ?>",
							width: "100%",
							aspectratio: "16:9"
							});
							</script>
							</div>
							<?php echo $fredi->hideTabs('delete|settings')->renderAll(); ?>
							<br />
							<h2> <?php echo $page->get('headline|title'); ?> </h2>
							<p>
							<?php
							// Render Year
							echo $page->year; echo " | ";

							// Render Runtime
							echo $page->runtime; echo " mins | ";

							// Get Classification and Render
							foreach($page->classification as $rating) {
                    		echo $rating->title; echo " | "; }

                    		// Get Genre and Render
                    		foreach($page->genre as $genre) { echo "{$genre->title} "; }
							?>
						</p>
						<hr />
							<?php echo $page->body; ?>
						</header>
						<?php foreach($page->images as $banner) echo "<span class='image featured'><img src='../../../site/assets/files/{$page->id}/{$banner->name}' alt='' /></span>"; ?>
					</section>
				</section>

			<!-- CTA -->
				<section id="cta">

					<h2>Want to know more about <b><?php echo $page->title; ?></b>?</h2>
					<p>Enter your email and we'll be in touch shortly.</p>

					<form>
						<div class="row uniform 50%">
							<div class="8u 12u(mobilep)">
								<input class="fit" type="email" name="email" id="email" placeholder="Email Address" />
							</div>
							<div class="4u 12u(mobilep)">
								<input type="submit" value="Sign Up" />
							</div>
						</div>
					</form>
				</section>
<?php include('./_footer.php'); ?>

Here's the current code from the template. Thanks Apeisa!

Link to comment
Share on other sites

  • Add page works fine without images / files. 

    I know this problem and used a "storage page" to store files and move them after the page is saved / created.

  • Users can modify the form with a simple url change. 
    /admin/page/fredi-field-edit/add/?parent_id=1160&template=basic-page&[b]fields=title|body|image[/b]&modal=1
    
  • Is a sanitizer used to clean the user input?

    Maybe you could add an additional param array (field -> sanitizer)? If a sanitizer is given, it will be used to clean the input value.

1. Yep, page needs to exist before files can be added to it. Maybe simplified page add and then show edit link for files? I am not planning to support files in add view.

2. Hmm.. I don't see this as an issue. Editing and adding pages with Fredi should be used for editors only: it uses many of the same methods than PW admin does. Same goes for edit links.

3. Inputfields are responsible for cleaning the data.

Link to comment
Share on other sites

Jonathan, not sure I know what is not working in your case?

Just tested this "echo $fredi->hideTabs('delete|settings')->renderAll();" on my install, and it works just fine (shows just children tab, editing and saving works normal).

Link to comment
Share on other sites

Not sure if this is related or not, but for my RestrictTabView module I conditionally added a hidden _pw_page_name field to the Content tab to deal with this: https://github.com/adrianbj/RestrictTabView/blob/master/RestrictTabView.module#L90

There is also this Issue that mentions the problems that can occur in certain configurations: https://github.com/ryancramerdesign/ProcessWire/issues/1048

Link to comment
Share on other sites

Soma and regesh: I am not able to reproduce the "Can't save page .. it has an empty "name" field" error on my test site. What kind of settings you have on template that is edited? I think it might have something to do with family or access settings (or then advanced).

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Hy,

Thanks for the module

I ve been testing fredy with pages (ie non admin pages) and have had no problem there.
But when I try to use fredy to edit users. There I encounter a strange behaviour. No matter what field I target the full user edit page appears in the modal window (with all of the users fields).

Is it a normal behavior. Did I miss something ? Is there some limitation while using users.

Today,

I tried to dig in a bit more. Did a fresh install (dev 2.6.15) and install fredy. I encounter the same probleme discribed above.

And found out also that the permission control that work with fredy for 'normal' pages doesn't work when  you r triying fredy to edit user. I gave editing rigth on the user template to one role. user having this role dont see the freedy edit link.

Juste in case i put an example of code I used in my test to output the fredy link.

$student = $users->get(1019);
echo $fredi->email($student);

thanks

Edited by antpre
Link to comment
Share on other sites

Another problem: If fields are declared as "required" and the fields are not filled out there will be no error message. The modal window will be closed and you have no hint that something is missing.

PS.: I use Reno theme and latest dev version of PW.

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
×
×
  • Create New...