-
Posts
148 -
Joined
-
Last visited
Profile Information
-
Gender
Male
-
Location
SF Bay Area
-
Interests
Photography, reading, cooking. My family. Systems and code that stand the test of time.
Recent Profile Visitors
3,670 profile views
bmacnaughton's Achievements
-
I am using the translation function (either $this->_() or __()) within a module that responds to AJAX API calls - there isn't really a page that is being served. When I supply a string with an apostrophe, e.g., __('Book \'em danno') It is formatted as Book 'em danno Is there some way to prevent output formatting when retrieving strings using the translation functions?
-
getLanguageValue equivalent for field labels
bmacnaughton replied to bmacnaughton's topic in API & Templates
Thank you for the precise and concise answer! It works quite nicely - even defaulting when a language doesn't have a value filled in. -
I would like to be able to fetch the labels for fields in a language different than the current logged in user. For field values that's easy // p is page, l is language, and f is field $p->getLanguageValue($l, $f); I'm looking for something like $fields->getLanguageValue('en', 'length'); The only solution I know of is to save the current user language, iterate through the languages by setting the user language and fetching the value, and then restore the user language.
-
Programmatic way to determine if field is multi-language?
bmacnaughton replied to bmacnaughton's topic in API & Templates
Thanks. I was trying to find out if a field was multiple language as opposed to there being language alternate fields. But I appreciate the link. -
Programmatic way to determine if field is multi-language?
bmacnaughton replied to bmacnaughton's topic in API & Templates
Perfect - thank you. -
Thank you @Zeka. Perfect answer, with code reference! I am getting more familiar with the code slowly.
-
When I delete a page name, e.g, /cart/, using the admin interface it goes into trash and gets the name /trash/2573.1.11_cart/ . I see that, with the Pages::trashed hook that the previous page name (previousPage) can be accessed. Where can I more information about what happens when a page is put into trash and what the name means?
-
I have a hook that creates a page for a subset of the pages on our site. It uses the saved page's name as part of the created page's name. The problem I am having is that my hook, attached to Pages::saved(), is being called even when the page save failed because of missing fields. Is there a way I can tell that the page save failed due to missing fields? Never mind - it does succeed; it just issues warnings about required fields.
-
bmacnaughton started following Pages::saved hook called even when failure
-
What's odd is that PW doesn't take all the data from the array passed to $form->process(). You can argue the CSRF protection is a different function, but that's just internal implementation. And it's easy enough to stuff things into $input->post, so it's not like it prevents forging.
-
You can stuff the values into $input->post or you can set the HTTP headers, so you can work around it.
-
How to capture page containing a pagetable?
bmacnaughton replied to bmacnaughton's topic in API & Templates
I tried the same thing - it was the last way I could think of. I'm not sure why it didn't work but will try again. -
How to capture page containing a pagetable?
bmacnaughton replied to bmacnaughton's topic in API & Templates
Thank you @Robin S. I am going to give this a try - I solved this particular problem by forcing the new entries under the page they are contained by but that is a suboptimal solution. -
How to capture page containing a pagetable?
bmacnaughton replied to bmacnaughton's topic in API & Templates
Thanks Abdus. I have a little different problem - I am looking for the specific page instance that has the field being edited. There are multiple pages based on the template that contains that field. I need to know which specific page instance is the "logical parent", not the set of pages that contain that field, i.e., are instances of the template that includes that PageTable field. To try to make it more concrete: PageA, PageB, and PageC all have the PageTable field Variations. When in the Admin interface PageA is being edited and the user wants to add a variation then they click "Add New" under Variations. At that point an iFrame overlay pops up to enter data for the new PageTable page in Variations. When that PageTable page is saved I need to know that it is associated with PageA. If the PageTable pages were in their default location (children of PageA) then I could just look at parent. But the PageTable pages are all kept in a single directory for grouping purposes. Make sense? -
When a PageTable field in a specific template is being edited I need to know the Page that contains the PageTable so I can fill in hidden fields in the PageTable. I can capture the page being edited via: // $this->addHookBefore('ProcessPageEdit::execute', ... public function pageEditExecuteBefore(HookEvent $e) { $p = $e->object->getPage(); if ($p->template !== 'rtw-product') return; // $p is the page being edited } I can intercept PageTable entry being saved: // $this->addHookBefore('Pages::save' public function savePageBefore (HookEvent $e) { $p = $this->wire('page')->id; $page = $e->arguments('page'); $obj = $e->object; $name = $page->name; // page name of PageTable page $template = $page->template->name; // template of PageTable page $parent = $page->parent->name; // parent directory for PageTable items What I am trying to find is the page in which the PageTable field is located. I've also tried having pageEditExecuteBefore() saving $p in $this->context and then accessing that in savePageBefore() but it's a different instance of the class because $this->context is null when it gets to savePageBefore(). I could save the page ID in session, but that seems error prone. Does anyone know how to achieve this?