-
Posts
691 -
Joined
-
Last visited
-
Days Won
6
Everything posted by thetuningspoon
-
I am trying to set a page field via the api using a string match, like so: $p->of(false); $p->company_select = 'My Company Name, Inc.'; $p->save(); This works fine for companies that do not contain a comma, but for those with a comma, no value is set. I'm wondering if ProcessWire is trying to split this into two different values and find a match for each separately? Is there some way I can escape the comma?
-
I also built a trip site with PW. I would probably suggest keeping the booking records in their own separate part of the page tree with a hidden parent page. Then have a Page field on the booking record which selects the Tour Date it is for. This would be the more traditional database method, though there are probably +/- to both ways of doing it. I used an integer field on the tour date to hold the number of slots available as well as the current number of bookings for that date, and automatically closed a date if it was full.
-
Strange errors following upgrade
thetuningspoon replied to thetuningspoon's topic in General Support
Okay, I think I've FINALLY narrowed this down to an issue with the new System Notifications module, which I have enabled on all of these sites. I disabled it on one of the sites and have not seen any errors from it since. It is the only module that uses FieldtypeMulti that is shared by all of the sites that are reporting the issue, and it is of course something that has changed/been added since 2.5. -
If anyone has trouble with this on 2.5 stable, let me know. I had some trouble with an install this morning and am looking into it.
-
Replacing a value in all fields that contain it
thetuningspoon replied to thetuningspoon's topic in API & Templates
Oops, this should be in the API forum... The "attempt" in my previous post seems to be working. If anyone else has ideas on ways to improve this, I'd be interested to hear them, though! -
Template 'Name format for children' expansion
thetuningspoon replied to SiNNuT's topic in Wishlist & Roadmap
If you look at the code for the name format for children feature, Ryan has a comment in there about adding the ability to base this off of any field. So I think it's on the to-do list -
Thanks for spotting that. I just needed to quote it properly, i.e. '2.0.0' I updated the version to 2.0.1.
-
This is something I thought would be pretty simple at first, but I'm having trouble figuring out the best way to accomplish it with PW's API: I want to look through all Page fields on my site and find all instances where they contain a certain page ID and replace it with a different page ID. Is there a way to do this directly with $fields or do I need to go through each $page and select the fields I want to modify by name? EDIT: Here's my first attempt at this. It seems pretty inefficient, though. // $p is the page with the id we want to replace // $newP is the page we're replacing it with // Create array of all the Page fields in the system $pageFields = wire('fields')->find("type=FieldtypePage"); foreach($pageFields as $pageField) { $pageFieldName = $pageField->name; $pageMatches = wire('pages')->find("$pageFieldName={$p->id}"); foreach($pageMatches as $pageMatch) { $pageMatch->$pageFieldName = $newP->id; // Replace the references with the new page $pageMatch->save(); } }
-
Hi BernhardB - The "Show edit links?" option should appear at the bottom of the "Input" tab in the global settings for the field. I'm a bit confused when you say "page body field" since the body field would be typically associated with a textarea and not a Page field. Let me know if you are still having issues and I will look further into it.
-
Page Field Edit Links GitHub: https://github.com/thetuningspoon/AdminPageFieldEditLinks Direct Download: https://github.com/thetuningspoon/AdminPageFieldEditLinks/archive/master.zip This module is based on--and is the successor to--Macrura's AdminPageSelectEditLinks (https://processwire.com/talk/topic/8477-adminpageselecteditlinks-module-for-enabling-edit-links-on-multipage-selects/) Page Field Edit Links adds modal editing capability to ProcessWire's Page fields in the admin editor, allowing editors to easily view and edit the content of any page(s) that have been selected, as well as create new pages without leaving the current screen. Edit links are updated in real time when new pages are added to the field. Compatible with all available types of Inputfields including Select, SelectMultiple, Checkboxes, Radios, AsmSelect, PageListSelect, PageListSelectMultiple, and PageAutocomplete.
- 101 replies
-
- 22
-
With field dependencies, it doesn't seem to be possible to show a field only if it is itself populated. I tried field_name!='' I know you can have a field collapsed if empty, but this could be a handy feature.
-
If I'm understanding correctly, it sounds like all you need to do is pull the title of the parent's parent page. So, something like this: <?= $new->parent->parent->title ?> For the current item should output the title of the site page. Or: <?= $new->parents->get('template=sitePageTemplateName')->title ?> might work if you don't want to have to specify exactly how many levels above your site page is. That will search all parents of the page until it finds the one with the specified template.
-
Strange errors following upgrade
thetuningspoon replied to thetuningspoon's topic in General Support
Still getting this on about 6 of my upgraded sites and am still at a loss. I disabled all 3rd party modules on one of the sites. No crons or lazy crons running... and I'm still getting the errors! I get them at least once a week, often a group of them every couple days or so, but no visible regularity to which sites they come from. Quite vexing. -
Macrura and I have put together a more definitive version of the editable page field which I will post to the module directory as soon as I get a chance. I agree, however, that a "page table meets page field" field is a must down the line. I have a scenario with a client right now where this would be the only ideal solution. The scenario: Client adds a company page with details about the company. Each company can have several contacts associated with it, such as a primary contact and an administrative contact. The user should be able to see some information about each contact at a glance (like a PageTable), and needs to be able to select a contact that already exists (like a Page field) but needs to be able to create and populate new contacts and have them automatically selected (like a PageTable).
-
Greetings from the world of Concrete5
thetuningspoon replied to jordanlev's topic in Getting Started
Each field actually has its own table in the database, so when you create a field, it is unique. Which is important because each field can be customized significantly with various options. As was mentioned, this also allows us to use the same field on multiple templates and query based on the content or existence of that field. I do sometimes wish that I could create multiple copies of any given field on a template and just modify the name without having to create a whole new field for it, but there might be trade-offs to something like that. In terms of the UI, you can now create a new field from within the template editor screen, though. -
Doing additional logic after saving a new page.
thetuningspoon replied to Brmm's topic in General Support
Ah, of course! Thanks guys!!- 23 replies
-
- page
- after saving
-
(and 1 more)
Tagged with:
-
Doing additional logic after saving a new page.
thetuningspoon replied to Brmm's topic in General Support
class AbcDatabase extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'ABC Database', 'version' => 001, 'summary' => 'Base module for the Database features', 'singular' => true, 'autoload' => true, 'installs' => array(), 'requires' => array(), ); } public function __construct() { } public function init() { $this->pages->addHookBefore('Pages::save', $this, "hookAutoPageName"); } public function ready() { // PW API is ready // Controllers go here } public function hookAutoPageName(HookEvent $event) { $pageid = $this->sanitizer->selectorValue($this->input->get->id); $page = $this->pages->get($pageid); // Bases the name of the company template off of the company_name field and keeps them in sync if($page->template == 'company') { if($page->company_name != '') { $newName = wire('sanitizer')->pageName($page->company_name, true); if($page->name == $newName) return; $pageMatch = $page->parent->child("name=$newName,include=all") ?: ''; if($pageMatch->id && $page->id != $pageMatch->id) { //This is a duplicate name, so we have to add an increment to avoid throwing error while($pageMatch->id) { $newName = $pageMatch->name . "-1"; $pageMatch = $page->parent->child("name=$newName,include=all") ?: ''; } $page->name = $newName; } else { $page->name = $newName; } } } } Below that is the install and uninstall functions and closing brace.- 23 replies
-
- page
- after saving
-
(and 1 more)
Tagged with:
-
Doing additional logic after saving a new page.
thetuningspoon replied to Brmm's topic in General Support
Sorry, I didn't make it clear: My question is whether this is the intended behavior. If it's not the intended behavior, I'll be happy to post some code.- 23 replies
-
- page
- after saving
-
(and 1 more)
Tagged with:
-
Doing additional logic after saving a new page.
thetuningspoon replied to Brmm's topic in General Support
I'm trying to add a hook which manipulates a particular page's name on save(). When I save the page using the admin, this works as expected. When creating or saving a page from the API, however, it doesn't seem to work. Why is that?- 23 replies
-
- page
- after saving
-
(and 1 more)
Tagged with:
-
New link Attributes tab not working in TinyMCE
thetuningspoon replied to thetuningspoon's topic in General Support
Yeah, I did. Ryan has now responded and said that TinyMCE will not support the new features at this time: https://github.com/ryancramerdesign/ProcessWire/issues/1057#issuecomment-90027374 -
New link Attributes tab not working in TinyMCE
thetuningspoon replied to thetuningspoon's topic in General Support
Good point, although the issue could still be on either end. I already posted it on the core issues, so I'll let Ryan do with it what he will. -
New link Attributes tab not working in TinyMCE
thetuningspoon replied to thetuningspoon's topic in General Support
An update: I've now observed this on multiple installations. I've cleared all caches and disabled all third party modules and am still having the issue, so I'll post it on GitHub. -
Strange errors following upgrade
thetuningspoon replied to thetuningspoon's topic in General Support
Thanks for the ->save() tip. I'll see what I can find. I was hoping there was some way to tell what table or row the error pertained to. -
Strange errors following upgrade
thetuningspoon replied to thetuningspoon's topic in General Support
Can the '41-0' provide me with any clue towards debugging this? If that is a pointer to an entry in the database, I could look it up in the database. I'm just not sure how that number maps to entries.