Jump to content

ridgedale

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by ridgedale

  1. Thanks for your reply @dragan . I've tried both the following with the same result of no output: admin.php: $mntvar = $upgradePage->maintainer; $_SESSION['mntnrvar'] = $mntvar; or: $mntvar = $upgradePage->maintainer; $_SESSION['mntnrvar'] = $_SESSION['mntvar']; and on the page redirected to: This website is currently undergoing maintenance by <?php echo($_SESSION['mntnrvar']); ?>. I'm not sure what I'm doing wrong. ?
  2. I am trying to pass a variable from ProcessWire to the outside world (for the purposes of page redirection). I've tried the following without any success: admin.php $session->mntnrvar = $upgradePage->maintainer; and on the page redirected to: <?php $mntnrvar = $session->mntnrvar; ?> This website is currently undergoing maintenance by <?php echo $mntnrvar; ?>. and: admin.php $mntvar = $upgradePage->maintainer; $GLOBALS['mntnrvar'] = $GLOBALS['mntvar']; and on the page redirected to: This website is currently undergoing maintenance by <?php echo $mntnrvar; ?>. In both cases $mntnrvar returns no data. The field is populated and the correct data is returned when called from within PW, but not when I try to pass the data outside of PW. Can anyone give me an idea where I am going wrong? Any assistance would be greatly appreciated.
  3. @dragan / @adrian , I'm very wary about the compatibility and stability of both of the CustomPageRoles and PageEditPerUser modules both being proof of concept modules and appear to lack PW3 compatibility. Having read through the thread for the DynamicRoles module via the link @dragan provided I think I will look at @matjazp's fork as @adrian suggested. Albeit I do have reservations given @Robin S 's comments regarding the DynamicRoles module in the following thread: Although I'm not sure if those comments apply to one, the other or both of @ryan 's module and @matjazp's fork.
  4. Thanks again for your assistamce, @dragan . Apologies. I realise that I have neglected to say that club users and entries administrators will have frontend access only. They only be submitting, checking and/or collecting data. Thank you for pointing out those modules. I'll look into them and see if they can help me get started.
  5. Hi @dragan , Thanks for your feedback once again. Apologies, I should have spotted that. ? I can simplify home.php and _main.php as follows: home.php: <?php namespace ProcessWire; // this homepage template demonstrates making the headline, body and sidebar fields // editable on the front-end, using the <edit> tags ?> <div class='uk-margin-top' id='content-body'> <?php echo $modules->get("LoginRegister")->execute(); ?> </div> _main.php: <?php namespace ProcessWire; // _main.php template file, called after a page’s template file $home = pages()->get('/'); // homepage $siteTitle = 'Regular'; $siteTagline = $home->summary; ?><!DOCTYPE html> <html lang="en"> <head id='html-head'> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title id='html-title'><?=page()->title?></title> <meta name="description" content="<?=page()->summary?>"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.30/css/uikit.min.css" /> <link rel="stylesheet" href="<?=urls()->templates?>styles/main.css"> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.30/js/uikit.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.30/js/uikit-icons.min.js"></script> <?php if(page()->comments): ?> <script src='<?=urls()->FieldtypeComments?>comments.min.js'></script> <link rel="stylesheet" href="<?=urls()->FieldtypeComments?>comments.css"> <?php endif; ?> </head> <body id='html-body'> <!-- MASTHEAD --> <header class='uk-background-muted'> <div id='masthead' class="uk-container"> <h2 id='masthead-logo' class='uk-text-center uk-margin-medium-top uk-margin-small-bottom'> <a href='<?=urls()->root?>'> <img src='<?=urls()->templates?>styles/images/coffee4.svg' alt='coffee'><br /> </a> <?=$siteTitle?> </h2> </div> </header> <!-- MAIN CONTENT --> <main id='main' class='uk-container uk-margin uk-margin-large-bottom'> <?php if(page()->parent->id > $home->id) echo ukBreadcrumb(page(), [ 'class' => 'uk-visible@m' ]); ?> <div class='uk-grid-large' uk-grid> <div id='content' class='uk-width-expand'> <h1 id='content-head' class='uk-margin-small-top'> <?=page()->get('headline|title')?> </h1> <div id='content-body'> <?=page()->body?> </div> </div> <aside id='sidebar' class='uk-width-1-3@m'> <?=page()->sidebar?> </aside> </div> </main> <?php if(config()->debug && user()->isSuperuser()): // display region debugging info ?> <section id='debug' class='uk-section uk-section-muted'> <div class='uk-container'> <!--PW-REGION-DEBUG--> </div> </section> <?php endif; ?> <!-- FOOTER --> <footer class='uk-section uk-section-secondary'> <div id='footer' class='uk-container'> <div uk-grid> <div class='uk-width-1-3@m uk-flex-last@m uk-text-center'> <form class='uk-search uk-search-default' action='<?=pages()->get('template=search')->url?>' method='get'> <button type='submit' class='uk-search-toggle uk-search-icon-flip' uk-search-icon></button> <input type='search' id='search-query' name='q' class='uk-search-input' placeholder='Search&hellip;'> </form> </div> <div class='uk-width-2-3@m uk-flex-first@m uk-text-center uk-text-left@m'> <h3 class='uk-margin-remove'> <?=$siteTitle?> <small class='uk-text-small uk-text-muted'><?=$siteTagline?></small> </h3> <p class='uk-margin-remove'> <small class='uk-text-small uk-text-muted'>&copy; <?=date('Y')?> &bull;</small> <a href='https://processwire.com'>Powered by ProcessWire CMS</a> </p> </div> </div> </div> </footer> </body> </html> Yes, I do understand as you pointed out in the answer to my previous topic, but my concern now is that adding fields and permissions to the user template may have a negative impact for the entry administrators. I would definitely prefer to use PW3 mode rather than creating MySQL tables. I am trying to get my head round how to build the entries system and drafting out table lists seemed a good place to start. One big initial concern I have is protecting the pages and data behind the login, and, secondly, I'm wondering whether or not the only way the two different user interfaces (club users/entries administrator(s) - menus providing page/data access) is to have two separate PW3 installations driven from the same database. Some data needs to be editable and read only to the club users and vice versa for the entries administrator(s). Is it possible to hide pages from some users and not others to present different navigation interfaces? As examples: A User Profile page will need to be editable by both the club users and the entries administrator(s). I'm thinking it might be better to setup a separate User Profile template that incorporates the fields used by the User template and add any additional fields to the User Profile template. Am I over-thinking/over-complicating things? The data for the Athlete pages should only be editable by the club user, not the entries administrator(s) who only need(s) read only/data export access, In addition, the relevant athlete data should only be accessible to the particular club to whom the athlete belongs. I don't know if this is correct or even possible, but it seems to me that I need a login.php page sitting in from of two home.php pages (one for the club users and one for the entries administrator(s). Have you or any other member of the PW community had to setup something similar before? If so, would it be possible to outline how it was achieved?
  6. Reference: PW 3.0.62 and uikit3 based site using the Regular-Master profile. I have some further questions having read the following thread: and the demo registration page referred to. I'm looking to setup a login page with no registration capability for club users to add/upload/manage their athlete entries. The entries administrator will manage the club logins and have access to a different set of pages (including some of the same pages). The club users are to be automatically directed initially to their profile page to update any required further information such as contact details. All users are to be required to login by user name not email address - one user name per club. Forgotten passwords will need to be requested from the entries administrator. The entries administrator is to be directed initially to an entries status page where the accepted and unaccepted athlete entries are listed for each club. The entries administrator should not be required to complete any further profile information. Any failed logins are to be redirected back to the login page. Initially I have replaced code in home.php with the following: <?php namespace ProcessWire; // this homepage template demonstrates making the headline, body and sidebar fields // editable on the front-end, using the <edit> tags ?> <div class='uk-margin-top' id='content-body'> <?php echo $modules->get("LoginRegister")->execute(); ?> </div> The only page accessible to guests needs to be the login page. How can I prevent guests bypassing the login page to guess and access the other pages of the website? Unpublishing the pages denies access to all users. Is the only way to create separate templates and deny access to pages created with them for guests? In addition, the Register for an account link needs to be removed. At this point I've created a list of tables and fields that I think will be required for the entries system: The available menus are to be different for the club users and entries administrator(s): If I've understood correctly, I need to create a template for each of the following Add then create individual pages for each club, season, fixture, category, race and club athletes. When the club user accesses the Athletes page s/he needs to be able to either add entries individually or import them via .csv upload effectively creating individual pages for each of the athletes (children of Athletes page) directly linked and only visible to the club. As is probably clear I have never created anything like this before. I'd appreciate any advice/assistance to help me get started.
  7. Hi @dragan , Thank you for your speedy reply and assistance. For anyone else encountering the same problem the route to Show system templates is as follows: Click on Admin (in the page tree) Click on Setup Click on Templates Click on the exposed View button Click on the Filters ... link at the top of the Templates page Then you will see the options displayed as per the image dragan provided above. Thanks again, dragan.
  8. Reference: PW 3.0.62 and uikit3 based site using the Regular-Master profile. I am in the process of looking into using the LoginRegister module to set up a login/registration page for team managers to login and register their athletes for a cross country league. I've got the initial installation of PW3 with the Regular-Master profile installed and installed the LoginRegister module. Now I want to add additional fields to the registration form, but cannot find the link referred to in the documentation: Setup > Templates > Show system templates > user I can't see Show system templates anywhere. Could someone kindly explain how I show the system templates so I can access the user template?
  9. @adrian Thank you for your reply and clarification. At present the solution outlined previously achieves the desired access control without the use of a role and/or module. I'll have to look into the ProtectedMode module further in due course.
  10. Thanks again @adrian for your further feedback. Understood. Would you mind sharing what those 2-3 major bugs are/were? Are you aware of any issues that might arise from an upgrade from the 3.0.62 master version to the 3.0.107 dev version? Whilst I appreciate that no software is perfect or bug free and agree with you that a greater emphasis should be placed on resolving existing issues, it would be helpful if the https://github.com/processwire/processwire-issues/issues could be filtered at least in terms of whether or not they relate to PW2 or PW3. I note there are no issues labelled as severity: low, severity: medium, severity: high or severity: critical and that 12 of the 216 current outstanding issues appear to have been fixed but have not been closed by the initiator. Do you have any advice on the best approach to filtering (via Labels) the issues to learn what issues may be of concern? Also what does the Authors dropdown menu refer to?
  11. @adrian Thank you for your reply. From the module description: it appeared to me that the ProtectedMode module would not be able to restrict front- and backend access to a single logged in superuser. Please correct me if my assumption was incorrect. The multi-site installation I am dealing with has multiple superusers. The solution arrived at, linked to in my previous post, allows a single superuser to manage the upgrade of ProcessWire blocking all other user access to all the websites until the PW upgrade has been completed and websites tested and brought back online, without the need for any modules.
  12. Update: See this topic that answers the above question raised.
  13. Hi @adrian , Thank you for your reply. If I were to be the only site superuser, that would be OK. However, other administrators will eventually take over in future and I personally think it would be safer to advise future superuser administrators that they should only upgrade to master ProcessWire versions to avoid/minimise potential upgrade issues. Other current and future superusers do not and and may not in some cases have the technical expertise to deal with the potential upgrade issues that may arise. Is there any thread available that monitors ProcessWire development progress and might give some idea when the next master release will be available?
  14. The multi-site installation I'm currently working on requires some of the new features/methods released in the 3.0.107 development branch. Does anyone have any idea when the next Processwire 3 master version is likely to be released?
  15. @Soma, Despite @Tom. mentioning this earlier for idiotic reason I have been placing the hook code in a ready.php file located in the site-xxx/templates directory instead of the site-xxx directory alongside the config.php file. Placing the code in the correct location resolves the issue and now everything is working as required. Sincere apologies for the oversight and thanks again to both of you for your assistance and patience.
  16. Hi @Soma , Thank you for your reply. I'm not sure I understand what you mean by this. Do you mean I should be using the second statement instead of the first? Otherwise what replacement should I be using? That makes sense and is why I also tried addHookAfter as well. Shouldn't an error have been displayed in the log to that effect? Neither of the following code changes for the ready.php file make any difference. The maintainer field still does not get updated without any errors being generated in the logs: <?php namespace ProcessWire; wire()->addHookAfter("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { if($page->maintenance) { $page->of(false); $page->maintainer = wire("user")->name; $page->save('maintainer'); } else { $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); <?php namespace ProcessWire; wire()->addHookBefore("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { if($page->maintenance) { $page->of(false); $page->maintainer = wire("user")->name; $page->save('maintainer'); } else { $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); That may be the case but the user cannot leave the page without saving it first. The user needs to check the maintenance field and save that field status (which actually does take place on saving the page) and the maintainer field automatically needs to be updated with the current username (which does not take place). Any further guidance would be greatly appreciated.
  17. Having found Ryan's post in this thread, I've also tried replacing the ready.php with the following code both without any success. The maintainer field does not get updated in the backend or the MySQL database: Further Testing 1: <?php namespace ProcessWire; wire()->addHookBefore("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->of(false); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user $page->save(); } else { // $page->setAndSave('maintainer', ''); $page->of(false); $page->maintainer = ''; $page->save(); } } }); Further Test 2: <?php namespace ProcessWire; wire()->addHookBefore("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->of(false); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user $page->save('maintainer'); } else { // $page->setAndSave('maintainer', ''); $page->of(false); $page->maintainer = ''; $page->save('maintainer'); } } }); I've also double-checked the logs and no errors are generated when the maintenance checkbox is ticked/unticked and the page saved. Changing addHookBefore to addHookAfter makes no difference. The only thing I can think of is to create a required dropdown menu field that just includes the current username, but I don't know how that can be achieved. Even so it is somewhat worrying that it appears field values cannot be set in the backend via the API. Any further input/thoughts would be very welcome.
  18. Hi @Tom. , I did a search for wire('config')->demo and found the following topic: and have downloaded the v.3 Skyscrapers profile from the link provided by @Robin S . That should provide the information I need. Many thanks again for your assistance and patience.
  19. Hi @Tom. , I've reviewed the Page Relationship field type. I don't think that field type is a applicable in this case. I'm simply using the Text field type for the maintainer field. Below is exactly the code tested in each of the files following your latest input: site-maintenance.php: <?php namespace ProcessWire; // site-maintenance.php template file for managing site upgrades and displaying maintenance status message. // Update the 'maintainer' field each time the maintenance checkbox is checked/unchecked. if ( ! $page->maintenance == 1) { // $page->setAndSave('maintainer', null); $mntmessage = "Status: This site is not currently undergoing maintenance."; } else { // $page->setAndSave('maintainer', $user->name); $mntnr = $page->get('maintainer'); $mntmessage = "Status: This site is currently undergoing maintenance by " . $mntnr . "."; } ?> <div pw-append='content-body'> <?php echo $mntmessage; ?> </div> <?php include('./_news-sidebar.php'); ?> ready.php: <?php namespace ProcessWire; wire()->addHookAfter("Pages::save", function($event) { $page = $event->arguments(0); if($page->template == 'site-maintenance') { // Replace 'site_upgrade' with your template name for the maintenance page if($page->maintenance) { // $page->setAndSave('maintainer', $user->name); $page->maintainer = $user->name; // If this field is a Page Relationship field it just needs to be $user } else { // $page->setAndSave('maintainer', ''); $page->maintainer = ''; } } }); Note: I've tried both the setAndSave alternatives in the if statement as well. 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. * */ $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->isLoggedin() && $user->name !== $upgradePage->maintainer) { $session->logout(); $session->redirect("/maintenance.html", false); exit; } require($config->paths->adminTemplates . 'controller.php'); Note: If the $upgradePage ... } is added everyone gets redirected to the maintenance.html page unless the maintainer field is manually updated. header.php: <?php namespace ProcessWire; $upgradePage = $pages->get('/site-upgrade/'); if($upgradePage->maintenance && $user->name !== $upgradePage->maintainer) { $session->logout(); $session->redirect("/maintenance.html", false); exit; } ?> <!DOCTYPE html> ... Note: && $user->name !== $upgradePage->maintainer needs to be included otherwise everyone including the site upgrade admin gets redirected. I need to ensure that the admin who checks the maintenance checkbox can login and review the sites to make sure everything is OK with the Processwire upgrade before making them live again. The maintainer field is still not being updated whether I use AddHookBefore or AddHookAfter methods or the setAndSave alternative instructions. When the checkbox is ticked by a logged in admin only the users with hasRole = guest get redirected. Anyone with a login is not redirected and could potentially interfere or cause problems for the site upgrade process. The only way the code works as intended is if I enter the admin username into the maintainer field manually. I just don't get why the maintainer field is not being updated. ?Any further thoughts?
  20. Thanks again for your reply, @Tom. OK, understood. The maintainer field is currently Type: Text. The only field types currently available are as attached. I'll read up on the Page Relationship field type, try the implementation suggested and let you know how I get on.
  21. Thanks again for your reply, @Tom. Unfortunately the https://processwire.com/demo/ isn't really very help as I would prefer that demo-admin users are able to view the backend interface they will very likely be using with all the current pages. I wonder: Is possible to set up a demo site based on an existing site and, if so, how to go about it?
  22. There is no need to apologise, Tom, for freely offering your time to help. Your assistance is greatly appreciated. Just to clarify, is the role "demo-user" a built-in role? If so, how do I assign it to a user, as that role does not currently exist? Also, does demo in: wire('config')->demo = true; to a built-in demo capability for any website? Or is demo something that needs to be setup?
  23. Hi Tom., Thanks again for the reply. I wasn't trying to hook anything. I was simply adding the code to the page template file. I've subsequently tried adding the following to the page template file also without any success: <?php namespace ProcessWire; // site-maint.php template file for managing site upgrades and displaying maintenance status message. $page->addHookAfter("save", null, "hookSiteMaintSave"); public function hookSiteMaintSave($event) { $page = $event->arguments[0]; $maintenance = $pages->get("/site-upgrade/")->maintenance; $maintainer = $pages->get("/site-upgrade/")->maintainer; if ( ! $page->maintenance == 1) { $page->setAndSave('maintainer', null); $maintmessage = "Status: This site is not currently undergoing maintenance."; } else { $page->setAndSave('maintainer', $user->name); $maintainer = $page->get('maintainer'); $maintmessage = "Status: This site is currently undergoing maintenance by " . $maintainer . "."; } } ?> This code applies to this page only - not to any other pages or templates. Is the code in the wrong location?
  24. Reference: PW 3.0.62 and uikit3 based site using the Regular-Master profile. I'm trying to automatically set and save a value to a field when a checkbox is checked on the same page under the backend. I've tried adding the following php code to the page without success: // Test 1 $maintenance = $pages->get("/site-upgrade/")->maintenance; $maintainer = $pages->get("/site-upgrade/")->maintainer; if ( ! $page->maintenance == 1) { $page->set('maintainer', null); $maintmessage = "Status: This site is not currently undergoing maintenance."; } else { $page->set('maintainer', $user->name); $maintainer = $page->get('maintainer'); $maintmessage = "Status: This site is currently undergoing maintenance by " . $maintainer . "."; } // Test 2 $maintenance = $pages->get("/site-upgrade/")->maintenance; $maintainer = $pages->get("/site-upgrade/")->maintainer; if ( ! $page->maintenance == 1) { $page->of(false); $page->maintainer = ''; $page->save(); $maintmessage = "Status: This site is not currently undergoing maintenance."; } else { $page->of(false); $page->maintainer = $user->name; $page->save(); $maintainer = $page->get('maintainer'); $maintmessage = "Status: This site is currently undergoing maintenance by " . $maintainer . "."; } // Test 3 $maintenance = $pages->get("/site-upgrade/")->maintenance; $maintainer = $pages->get("/site-upgrade/")->maintainer; if ( ! $page->maintenance == 1) { $page->setAndSave('maintainer', null); $maintmessage = "Status: This site is not currently undergoing maintenance."; } else { $page->setAndSave('maintainer', $user->name); $maintainer = $page->get('maintainer'); $maintmessage = "Status: This site is currently undergoing maintenance by " . $maintainer . "."; } In all cases the maintainer remains blank when the maintenance checkbox is checked. Any guidance as to where I'm going wrong would be greatly appreciated.
×
×
  • Create New...