Jump to content

ridgedale

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by ridgedale

  1. Finally, I've managed to get the frontend editing and data display working as I think it is intended. Below is an excerpt of the sample data posted earlier that has been updated and appears to work: <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $T_Title ?></h5> <table class="uk-table"> <?php foreach($page->children() as $p) { if(empty($p->T_First_Name)) { $p->of(false); $p->T_First_Name = ' ... '; $p->of(true); } if(empty($p->T_Last_Name)) { $p->of(false); $p->T_Last_Name = ' ... '; $p->of(true); } if(empty($p->T_Phone)) { $p->of(false); $p->T_Phone = ' ... '; $p->of(true); } if(empty($p->T_Email)) { $p->of(false); $p->T_Email = ' ... '; $p->of(true); } } ?> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"> <?php if(!empty($page->T_First_Name)): ?> <edit field='T_First_Name'><?=page()->T_First_Name?></edit> <?php endif; ?> <?php if(empty($page->T_First_Name)): ?> <edit field='T_First_Name'><?=$p->T_First_Name?></edit> <?php endif; ?> </td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"> <?php if(!empty($page->T_Last_Name)): ?> <edit field='T_Last_Name'><?=page()->T_Last_Name?></edit> <?php endif; ?> <?php if(empty($page->T_Last_Name)): ?> <edit field='T_Last_Name'><?=$p->T_Last_Name?></edit> <?php endif; ?> </td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"> <?php if(!empty($page->T_Phone)): ?> <edit field='T_Phone'><?=page()->T_Phone?></edit> <?php endif; ?> <?php if(empty($page->T_Phone)): ?> <edit field='T_Phone'><?=$p->T_Phone?></edit> <?php endif; ?> </td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"> <?php if(!empty($page->T_Email)): ?> <edit field='T_Email'><?=page()->T_Email?></edit> <?php endif; ?> <?php if(empty($page->T_Email)): ?> <edit field='T_Email'><?=$p->T_Email?></edit> <?php endif; ?> </td> </tr> </tbody> </table> </div> The only problem with this is that if the text to be entered is long it will break out of the display area and make the page layout look very messy. The solution to this would appear to be to display the text to be entered or edited within inputs, but the various methods of incorporating the editable data into an <input> element I've tried so far but so far have failed to work. The data is either displayed outside of the <input> or the data becomes uneditable, or the data appears to be editable but does not get saved. Has anyone found a way to display editable data within an input to allow the data to be edited and updated? Any assistance would be appreciated.
  2. @horst , Just a quick update. I've made some progress. I realised this particular instance of PW3 had not been upgraded to 3.0.111. Apologies for that oversight. Following the upgrade to 3.0.111 the additional text is now being injected and displayed using the following code. This is the code that now allows the field to be edited. The original style code did not allow the field to be edited: However, when I edit and save any changes the field continues to display the ellipsis even though the changed data appears on the page in the backend. So I tried changing the above code as follows: <?php if(!empty(page()->T_First_Name)) { page()->T_First_Name; } else { $p->T_First_Name; }?> But that causes the field to apparently display as blank again event though again the field contains the edited data in the backend. I also tried editing the foreach statement similarly with the same results. I can't see what I'm doing wrong. Any ideas?
  3. @horst , Further update. Does Processwire need to somehow be restarted after the config change? I've added the following to the end of the site/config.php file and refreshed the browser in the backend. I have tried the following changes to the table elements without any success: <edit field='First_Name'><?=page()->$p->First_Name?></edit> or <edit field='First_Name'><?=$p->First_Name?></edit> and both return the following error: When I try the following code: <?=$p->edit('First_Name')?> I get the following error: In each case the errors are referring to the <td></td> element containing $p. I can't see what I'm doing wrong. The initial php code is inserted in the same manner directly after <table>. The full code for the template is as follows: <?php namespace ProcessWire; // this template is very much like the basic-page template except that it // demonstrates making the headline, body and sidebar fields editable on the // front-end, using the <edit> tags $p = ''; ?> <h1 id='content-head'>Name Profile</h1> <div id='content-body'> <h3><?=page()->Name?> - <?=page()->Code?></h3> <div class="uk-grid uk-grid-small xzxzx-grid-spacer"> <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $M_Title ?></h5> <table class="uk-table"> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"><edit field='M_First_Name'><?=page()->M_First_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"><edit field='M_Last_Name'><?=page()->M_Last_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"><edit field='M_Phone'><?=page()->M_Phone?></edit></td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"><edit field='M_Email'><?=page()->M_Email?></edit></td> </tr> </tbody> </table> </div> <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $D_Title ?></h5> <table class="uk-table"> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"><edit field='D_First_Name'><?=page()->D_First_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"><edit field='D_Last_Name'><?=page()->D_Last_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"><edit field='D_Phone'><?=page()->D_Phone?></edit></td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"><edit field='D_Email'><?=page()->D_Email?></edit></td> </tr> </tbody> </table> </div> <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $C_Title ?></h5> <table class="uk-table"> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"><edit field='C_First_Name'><?=page()->C_First_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"><edit field='C_Last_Name'><?=page()->C_Last_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"><edit field='C_Phone'><?=page()->C_Manager_Phone?></edit></td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"><edit field='C_Email'><?=page()->C_Manager_Email?></edit></td> </tr> </tbody> </table> </div> <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $S_Title ?></h5> <table class="uk-table"> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"><edit field='S_First_Name'><?=page()->S_First_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"><edit field='S_Last_Name'><?=page()->S_Last_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"><edit field='S_Phone'><?=page()->S_Phone?></edit></td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"><edit field='S_Email'><?=page()->S_Email?></edit></td> </tr> </tbody> </table> </div> <div class="uk-width-1-1@s uk-width-1-2@m xzxzx-grid-block-spacer"> <h5><?php echo $T_Title ?></h5> <table class="uk-table"> <?php foreach($page->children() as $p) { if(empty($p->T_First_Name)) { $p->of(false); $p->T_First_Name = ' ... '; $p->of(true); } if(empty($p->T_Last_Name)) { $p->of(false); $p->T_Last_Name = ' ... '; $p->of(true); } if(empty($p->T_Phone)) { $p->of(false); $p->T_Phone = ' ... '; $p->of(true); } if(empty($p->T_Email)) { $p->of(false); $p->T_Email = ' ... '; $p->of(true); } } ?> <tbody> <tr> <td class="xzxzx-field-label">First Name:</td> <td class="xzxzx-field"><edit field='T_First_Name'><?=$p->T_First_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Last Name:</td> <td class="xzxzx-field"><edit field='T_Last_Name'><?=$p->T_Last_Name?></edit></td> </tr> <tr> <td class="xzxzx-field-label">Phone:</td> <td class="xzxzx-field"><edit field='T_Phone'><?=$p->T_Phone?></edit></td> </tr> <tr> <td class="xzxzx-field-label xzxzx-last-row">Email:</td> <td class="xzxzx-field"><?=$p->edit('T_Email')?></td> </tr> </tbody> </table> </div> </div> </div> <?php include('./_sidebar.php'); ?> It doesn't seem to matter where I place php foreach declaration. The same errors occur. I clearly must be doing something wrong. 😞 Any ideas appreciated and thanks for your patience.
  4. Thanks for the heads-up, @horst . I presume I just need to add this the end of the site/config.php file. Is that quote from your site/config.php file and are those your comments to yourself for reference?
  5. @kongondo , Thank you for your reply. Apologies for the confusion caused by my sample code. In answer to your questions: 1. At present the buttons do nothing. They are buttons with a hashed link. 2. They are located on the club (parent) page and not in a form as I thought the idea might be to link to the page that runs the code required to create the page(s) - the members (child) page. 3. I haven't got that far yet as I wasn't sure where the form should be run from. Should the form be run from the parent to create the page(s) using the child template? 4. Yes the intention is for the form handling to be server-side. 5. I can see /path/page.php was unhelpful, if not, misleading. My thinking was that it represented the path to the template where the processing is to take place. In this case I am not sure if the target should be the parent template (i.e. the template of the page the buttons are located on) or the child template (the target for the creation of the page(s) I have no experience of working with AJAX. Is it not possible to use PHP, Javascript and/or JQuery to achieve the same goal? Or is this a case of those tools not being the right tools for the job? Below is some code for the form: <div id="member-form"> <form id="memform" action="./" method="post" class="uk-grid-small" uk-grid> <div class="uk-width-1-2@s"> <label for="First_Name" class="uk-form-label">First Name: <span class="required">*</span></label> <input placeholder="First Name..." class="uk-input" type="text" tabindex="1" name="First_Name" value="" /> <span class="form-error"></span> </div> <div class="uk-width-1-2@s"> <label for="Last_Name" class="uk-form-label">Last Name: <span class="required">*</span></label> <input placeholder="Last Name..." class="uk-input" type="text" tabindex="2" name="Last_Name" value="" /> <span class="form-error"></span> </div> <div class="uk-width-1-2@s"> <label for="Licence" class="uk-form-label">Licence: <span class="required">*</span></label> <input placeholder="Licence..." class="uk-input" type="number" tabindex="3" name="Licence" value="" /> <span class="form-error"></span> </div> <div class="uk-width-1-2@s"> <label for="Date_of_Birth" class="uk-form-label">Date of Birth: <span class="required">*</span></label> <input placeholder="Date of birth..." class="uk-input" type="date" tabindex="4" name="Date_of_Birth" value="" /> <span class="form-error"></span> </div> <div class="uk-width-1-2@s"> <label for="Gender" class="uk-form-label">Gender: <span class="required">*</span></label> <select class="uk-select" tabindex="5" name="Gender"> <option value="" >Select a gender...</option> <option value="1" >Female</option> <option value="2" >Male</option> </select> <span class="form-error"></span> </div> <div class="uk-width-1-2@s"> <label for="Category" class="uk-form-label">Category: <span class="required">*</span></label> <select class="uk-select" tabindex="6" name="Category"> <option value="" >Select a category...</option> <option value="1" >A</option> <option value="2" >B</option> <option value="3" >C</option> <option value="4" >D</option> <option value="5" >E</option> </select> <span class="form-error"></span> </div> <div class="uk-width-1-1"> <p class="my-note"><span class="required">Note:</span> The fields marked <span class="required">*</span> are required.</p> </div> <div class="uk-width-1-1 buttons-center"> <button id="myform-submit" class="uk-button uk-button-primary uk-button-small" type="submit" name="submit" value="submit">Submit</button> <button id="myform-reset" class="uk-button uk-button-secondary uk-button-small" type="reset" name="reset">Reset</button> </div> </form> </div> The new child page needs to be created using the child template. In addition, the contents of the logged in user's profile Club_Code field needs to automatically be copied into an equivalent field of the newly created (member) child page. There is also no title field included in the member template as there is no need for it. Can the page name be generated as an auto-incrementing id number? I think I am beginning to understand. The form needs to be run from the parent page in order to create the child page(s). Is that correct? Is it possible for the form to be displayed in a pop-up window? If so that would appear to me to be a more logical user interface. The user clicks on the button to launch the form in the pop-up window or launch a form to upload a .csv file. I will read through the information you provided via the link now. Thanks for your patience.
  6. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. Despite my searches of the forum I'm somewhat confused about how to create new child pages on the frontend when a user clicks on a button on the parent page. I also have an equivalent button that is intended for uploading a .csv file to automatically create multiple new pages. This basically relates to a club (parent) and members (child) template configuration. Hopefully this explanation makes sense. A button should be able to launch the code needed to initiate the script required to create a new page using something like: <a href="/path/page.php">New +</a> <a href="/path/page.php">New ++</a> Does the code to create the new page or new pages need to be run from the template file for the child or the parent? A new individual member page will need to be editable manually at the point of page creation as well as subsequently, whereas multiple new pages will need to be editable after they have created and populated with data, again, as well as subsequently. I would very grateful for any advice or pointers as to how to achieve this.
  7. @horst , Thank you for your reply. I've tried the code you kindly provided and initially got an undefined $p error so I added $p = '' the top of the template and then refreshed the page and now I'm getting the following error: Fatal error: Call to a member function edit() on string in /home/.../templates/club.php on line 71 That relates to the first instance of: <?=$p->edit('... I don't know if this makes a difference but the code I'm currently using to display the fields is as follows: <edit field='Field_Name'><?=page()->Field_Name?></edit> I'm clearly not doing something right or have misunderstood how to implement the code. Any help would be greatly appreciated.
  8. @kongondo , Thank you for your reply. Yes that's correct, to be displayed on the frontend. When I have tested hiding the Login (home) page PW3 appeared to ignore the setting change for page and does not appear possible to remove the view attribute for the login/register role. I've managed to achieve what I need by creating static navigation using the Uikit framework. It would be useful to be able to control this from within PW3, though.
  9. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I was wondering if there is a way to restrict user navigation to specific pages. Login (home.php - not to be displayed) |__ About (not to be displayed) |__ Clubs (not to be displayed) | |__ Club (to be displayed) | |__ Club Members (to be displayed) |__ League (not to be displayed) | |__Season (not to be displayed) | |__ Match (not to be displayed) |__ News (blog.php - to be displayed) | etc, etc Based on the above the navigation needs to appear simply as: --------------------------------------------------------------------------- Club Club Members News --------------------------------------------------------------------------- Any thoughts appreciated.
  10. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I am trying to create a process whereby when a user logs in to their profile page (the user is automatically redirected to their profile page on login) and they then go to their 'members' page and creates a child page ('club-member'), the data stored in the user template ($user->usercode) is automatically added to the equivalent field on the club-member page. This will be applicable only to the template used for the 'club-member' pages. Once the new page has been created the equivalent 'usercode' field on the 'club-member' page should not be subsequently editable. Below is the page hierarchy for visual reference: Login (home) |__ profile |__ members |__ club-members It seems like an AddHookBefore might be the solution here such as: wire()->addHookBefore("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->template == 'club-member') { $clubcode = $user->club_code; $field = $page->club_code; $field->set('value', $clubcode); } }); I am I on the right track or is there a better way to achieve this? Any thoughts appreciated.
  11. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I've setup a page where a member can edit contact details via the frontend displaying the field content using the <edit> ... </edit> tags. This works fine when the fields actually contain data. However fields that contain no data (i.e. empty) do not appear to be editable. No edit cursor appears (- possibly owing to the field width being 0px?) Is the only solution to recreate the page using a form, for example, or is there a simple way to allow blank fields to be editable on the frontend? I wondered if anyone else has found a solution to this problem. Any assistance would be appreciated.
  12. @BitPoet , Thanks for the clarification. That's greatly appreciated. That's how I'm intending using it. So I'm glad I'm on the right track. Many thanks again for your reply.
  13. @bernhard , Thanks for the prompt reply and apologies for my oversight. I must be getting tired, I thought I had checked the core modules. 😞 I'm a little surprised that module is not installed by default. Is there a particular reason it isn't?
  14. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I am trying to add a field that provides a dropdown menu but there are no Options or Selector(s) type available - see attached image of field types available. The following reference under the docs does not appear to be applicable any more: https://processwire.com/api/modules/select-options-fieldtype/ I can't see how to achieve this. Any assistance would be appreciated.
  15. @louisstephens @jmartsch , Thank you both for your speedy solutions. Much appreciated. I think I tried that as well making the same mistake. 😞 Thanks again to you both.
  16. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I'm trying to automatically redirect a logged-in user to a custom profile page using $session->redirect() and need to add $user->name to the redirect path. All my attempts appear to have failed: $session->redirect('/user-profile/')->name; $session->redirect('/user-profile/')->$user->name; $session->redirect('/user-profile/' . get($user->name . '/')); $session->redirect('/user-profile/' & get($user->name)); Can anyone point out where I am going wrong?
  17. Thank you for your feedback @kongondo and insight. I think at this stage the solution in the short-term is to only allow superusers to create/edit/remove roles and enable just the user-admin and user-admin-all permissions for sitemanagers to allow them to be able to assign the roles pre-defined by superusers. It will also keep the administration simple for future supersusers. Thanks again to both of you for your assistance.
  18. Update: I can see adding the permission-admin permission to the sitemanager role gives the sitemanager access to all site permissions effectively allowing him/her to create a superuser equivalent role. That is definitely not what I am aiming for. Is it possible to restrict the permissions the sitemanager can give/remove to those assigned to the sitemanager role? Otherwise are there any alternative suggestions as to how to restrict sitemanager access, so s/he does not have access to modules, templates, fields and logs, but can manage users, roles and permissions at their own level or below?
  19. Hi @Robin S , Thank you again for your reply and detailed instructions. I am very conscious of the potential pitfalls. What I am aiming to achieve overall is that sitmanagers only have control to manage roles and assign permissions that are equal to and beneath their own assigned rights. I hope that makes sense. The reason for not allowing sitemanagers to be superusers in this particular instance is that it is a multi-site installation where we don't want sitemanagers creating/editing/deleting templates/fields/logs and/or installing modules. All the sites are effectively run using identical templates and modules. If we allow sitemanagers that level of control it will inevitably lead to an administrative nightmre for the superusers in the long run. I will delve deeper and look further into this. Many thanks again for your guidance.
  20. Hi @Robin S , Thanks again for responding. What I was doing was following the guidelines provided here: https://processwire.com/api/user-access/permissions/#user-admin-permissions I had missed the following little nugget of information: Now that the sitemanager can add/remove users s/he still does not have any access to add/remove roles or assign permissions despite the role-admin permission having been added and assigned to sitemanager. The Role menu item is displayed but no sub-menus are available and no Permissions menu is displayed at all. Not sure what I'm doing wrong, now. Any guidance appreciated.
  21. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I wonder if anyone might be able to point me in the right direction. I need to restrict the superuser role to overall administrators of a group of sites, but provide role and permission administration for the administrators of the individual sites. My searches unearthed the following thread: However, after having already created the sitemanager role and given site administrators the user-admin permission and having then created the role-admin permission and assigned that to the sitemanager role, the users with sitemanager permissions are able to see the Roles item under the Access menu of the backend but no submenu is displayed showing the Add Role option or any of the roles that the administrator should have access to. My intention is that the individual site adminstrators should have access to assign the guest and sitemanager roles (but not edit them) and be able to create roles with privileges beneath that of sitemanager. Any advice would be greatly appreciated.
  22. For the record I managed to resolve the issue by using the following code: admin.php: <?php namespace ProcessWire; /** * Admin template just loads the admin application controller, * and admin is just an application built on top of ProcessWire. * * This demonstrates how you can use ProcessWire as a front-end * to another application. * * Feel free to hook admin-specific functionality from this file, * but remember to leave the require() statement below at the end. * */ session_start(); $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->isLoggedin() && $user->name !== $upgradePage->maintainer) { $session->logout(); $mntvar = $upgradePage->maintainer; $redirurl = "/mntadm.php?upgadm=" . $mntvar; $session->redirect($redirurl, false); exit; } require($config->paths->adminTemplates . 'controller.php'); with the code for the target mntadm.php file being: <?php session_start(); ?> <!DOCTYPE html> <html> <body> <?php echo "<p>This website is currently undergoing maintenance by " . $_GET['upgadm'] . ".</p>"; ?> </body> </html> Thanks again to everyone for their input.
  23. Hi bernhard, Thank you for your reply. The maintainer field (located on the site-upgrade page within PW) holds the name of the person carrying out the maintenance. I'm trying to pass that name via (a) variable(s) to a page located outside PW. I don't want anyone other than the person carrying out the site maintenance logging into the site for the duration of the maintenance. Hopefully that clarifies things.
  24. Thanks for the feedback, horst. Apologies. I'll try to bear that in mind in future.
  25. Thank you again for your reply. Regarding: $upgradePage is the PW variable for the path to the page and maintainer is the field containing the data. Despite double-checking the PHP manual I can still not get the data passed between the pages. Below is the full relevant code: admin.php: <?php namespace ProcessWire; /** * Admin template just loads the admin application controller, * and admin is just an application built on top of ProcessWire. * * This demonstrates how you can use ProcessWire as a front-end * to another application. * * Feel free to hook admin-specific functionality from this file, * but remember to leave the require() statement below at the end. * */ session_start(); $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->isLoggedin() && $user->name !== $upgradePage->maintainer) { $session->logout(); $mntvar = $upgradePage->maintainer; $_SESSION["mntnrvar"] = $_SESSION["mntvar"]; $session->redirect("/mntadm.php", false); exit; } require($config->paths->adminTemplates . 'controller.php'); and the code for the target mntadm.php file is: <?php session_start(); ?> <!DOCTYPE html> <html> <body> <?php echo "<p>This website is currently undergoing maintenance by " . $_SESSION["mntnrvar"] . ".</p>"; ?> </body> </html> Everything works as intended apart from the maintainer data being passed.
×
×
  • Create New...