Jump to content

bmacnaughton

Members
  • 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,433 profile views

bmacnaughton's Achievements

Sr. Member

Sr. Member (5/6)

35

Reputation

1

Community Answers

  1. 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?
  2. Thank you for the precise and concise answer! It works quite nicely - even defaulting when a language doesn't have a value filled in.
  3. 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.
  4. 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.
  5. Is there a way to tell if a field is a multi-language field? I am currently checking to see if the last 8 characters are 'Language' but that seems like a fragile solution.
  6. Thank you @Zeka. Perfect answer, with code reference! I am getting more familiar with the code slowly.
  7. 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?
  8. 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.
  9. 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.
  10. You can stuff the values into $input->post or you can set the HTTP headers, so you can work around it.
  11. 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.
  12. 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.
  13. 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?
  14. 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?
×
×
  • Create New...