• Content count

  • Joined

  • Last visited

Community Reputation

24 Excellent

About bmacnaughton

  • Rank
    Sr. Member

Profile Information

  • Gender
  • Location
    SF Bay Area
  • Interests
    Photography, reading, cooking. My family. Systems and code that stand the test of time.

Recent Profile Visitors

1,485 profile views
  1. Thank you. I really appreciate the link and the code being on github. I learn a lot by reading code and yours is very helpful. I've solved the problem for one template but your solution is more general so when the inevitable additional template comes along, I'll most likely move to your module. Thanks for putting it together and pointing me at it.
  2. Do any experts have experience with the level of stability and/or support for turning on $config->advanced? I ask because of the warning at the bottom of the System tab "Please note that all of these system settings are intended for ProcessWire system development (not site development). Use them at your own risk." It provides two facilities that are invaluable to me (maybe because I don't know how to do them any other way). 1) Disable Settings Tab on a per template basis 2) Page Class Name - this makes it tweak a page while relying on the underlying Page class for the majority of functions. Are others using this setting in production? Have you used it over an extended time and seen that it is not changed often or at all?
  3. I'm working in version 3 and can't remove the settings tab using your example. Maybe something new has changed? But $config->advanced = true; works perfectly and is a better solution as it's already per-template.
  4. Woohoo! Thanks. $config->advanced = true; does the trick!
  5. I found this in the meantime - thanks for this post as well. I got the this working by turning on $config->advanced = true; in config.php which allows hiding the settings tab on a per-template basis! Nice. It seems that the code in the thread turns off the general ProcessWire menus as well: Before and after shots attached. I'm working on 2) now.
  6. Soma, Thank you so much for this. It's a fantastic example which I'm using as of yesterday. I particularly appreciate you posting clean code as I find reading code the best way for me to learn how things work. Do you possibly have any examples of a hook in which I could manipulate more of the admin interface? I'd like to do a couple things: 1. Remove the "settings tab" in the iframe that pops up when editing a PageTable entry. Maybe it's possible to do so with roles and permissions or a technique similar to removing the button. 2. Change the function of the "Add New" button completely - don't create/load the iframe and just create a new PageTable entry programmatically. If there are hooks to point me at I can figure them out. I've spent time with Captain Hook and but am a bit overwhelmed with the sheer number as well as the fact that I don't know much about how the admin interface is constructed.
  7. Is it possible to rename the page after it's been added to the Page Table? In the admin interface there is an "Add New" button for Page Table fields. I am trying to set the name of the page being created based on content that is entered into the page in the "Add New" overlay dialog. Is that possible without editing ProcessWire source code? It seems like the name has already been entered into the PageTable before the new page is created and that might be why hooking 'setupPageName' is not effective.
  8. OK, I was too quick to assume it would work. The hook is invoked with a page name like 20170422-011158. As shown in the following code I try to insert 'temp-' in front of the timestamp-based name. $name = 'temp-' . $event->return; $event->return = $name; But the $event->return value is not being used. What am I doing wrong? Is there some special about Page Tables that this doesn't work for?
  9. OK, I've got this one solved. Hook 'Pages::setupPageName'. Working on the next one.
  10. I have a Page Table field that, for new entries, I want to construct the name for. When I click the Add New button the page being added has already been given a random name like: 20170422-003744. I wish to 1) change that name so it's obvious it is a temporary name and 2) when either Publish or Save + Keep Unpublished is clicked, set the name of the page based on the content entered. What hooks can I use to accomplish 1 and 2? thanks.
  11. That's getting there - if I were in control of $sanitizer then I'd be set. But I'm creating a page via API so my code looks like (and sorry, I should have included this): $p = new Page(); $p->template = 'template-name'; $p->name = "$prod--$variation"; So I don't have control over calling $sanitizer - PW is doing that internally.
  12. That doesn't actually change the page name though - I already have what I want in $name, right?
  13. I'm trying to create a pagename (for internal use, not for presentation to the users) with multiple dashes in the middle. Here's an excerpt of my code: $p = new Page(); $p->template = 'template-name'; $p->name = "$prod--$variation"; ProcessWire seems to apply $sanitizer->pageName($name, true) which converts multiple dashes to a single dash so the page name doesn't have "--" in it. How can I force it to have multiple dashes?
  14. Thanks. I hadn't seen those functions. Any idea why it doesn't return a language-specific name by default? The URL is language-specific by default, so $page->localUrl() isn't really needed as I can get that value just by using $page->url.
  15. We have a three language web site - 'de', 'en', 'fr' with 'de' being the default. There are pages for which we want to use the name (it's unique within its parent-scope) as in the attachment. But when I fetch the name it does not return the name for the language - it always returns the name for the default language (guertel, in this case). I've tried $page->getLanguageValue($lang, 'name'), but name is not a "real" field, so it returns null. I can hack around it by extracting the last segment of the URL associated with that page (which is language sensitive) but it seems like I must be missing something. Is there some way to fetch $page->name for the $user->language setting?