Jump to content

Martin Muzatko

Members
  • Posts

    50
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.happy-css.com

Profile Information

  • Gender
    Male
  • Location
    Stuttgart, Germany
  • Interests
    Everything Webdev.
    I'm a passionate Designer and Developer. Always eager to bring love to the world in shape of software and knowledge.

Recent Profile Visitors

9,904 profile views

Martin Muzatko's Achievements

Full Member

Full Member (4/6)

22

Reputation

  1. Is "custom_sort" a builtin of processwire? I wouldn't want to implement an extra field for that. Also: Since contentmodules can also be re-used on other pages, I don't know if setting the sorting on the page itself would help.
  2. I need to programmatically SET the order/sorting of the pages, not when getting the pages from the page selector field. The problem is, that setting the manual sort value of the page won't help, as they are neglected by the page reference field. To tell the full story: I'm building a CMS in a CMS. pageModules are set via Rest API: function setPageModules($page, $data, $contentPage = false) { $page->of(false); $pages = $page->pageModules; if (!$contentPage) { $contentPage = wire('pages')->get('template=page-contents'); } foreach ($data as $key => $moduleData) { if(isset($moduleData->id)) { $module = wire('pages')->get($moduleData->id); $module->of(false); setFieldValues($moduleData, $module); $module->save(); } else { $module = new Page(); $module->parent = $contentPage; $module->of(false); $module->template = $moduleData->template; $module->title = $page->title.'_'.$moduleData->template; $module->save(); $module->of(false); setFieldValues($moduleData, $module); $module->save(); $moduleData->id = $module->id; $page->pageModules->add($module); } } $page->save(); $page->of(false); foreach($data as $key => $moduleData) { // TODO: SORTING! // $module = wire('pages')->get($moduleData->id); // $module->sort = $key + 1; // $module->save(); } $page->pageModules->save(); foreach ($page->pageModules as $module) { $index = array_filter($data, function($item) use ($module) { return $item->id == $module->id; }); if (!count($index)) { $module->delete(true); } } $page->save(); } the $contentPage holds all content modules ever created. So it gets quite messy: So now I need to set the sorting, defined by the user input ( I get an array ob content module objects via my rest API) But there is no way to set the manual sorting of a page reference field. I will look through your thread horst. Thanks!
  3. Hello! I want to set the manual page sort of a page reference field with a pageArray. I found this existing thread which does not answer the question unfortunately. https://processwire.com/talk/topic/18510-sort-page-reference-field/?tab=comments#comment-162124 It looks like there are different concepts of sort. One that works with properties (sort=created) and one with a page as argument and index as second. However, I found this in wire\modules\Inputfield\InputfieldPage\InputfieldPage.module, that may explain how sorting is done when doing manual drag and drop. How can I reproduce that for my own sorting? // if pages were added, re-sort them in case they were dragged to a different order // an example of this would be when used with the InputfieldPageAutocomplete if(count($this->pagesAdded) && is_array($value)) { $sortedValue = $this->wire('pages')->newPageArray(); foreach($newValue as $page) { if($page->id < 1) $page = $this->pagesAdded->shift(); if($page->id && !$sortedValue->has($page)) $sortedValue->add($page); } $newValue = $sortedValue; $this->setAttribute('value', $newValue); }
  4. Hello! Can somebody else please take care of this? I'm deep in projects as of now. Otherwise, I will look into it later. Best, Martin
  5. See gif: When I use $sanitizer->pageName() to sanitize a title as name, I get a different result from what processwire automatically replaces, when editing the name in the CMS. I have to manually replace the dashes and even dots! I would expect the name to be equal to the last segment of the pagepath.
  6. It might be important to note, that while the path can be accessed via ->path, if the field is a multiple-image field. (Pageimages) Otherwise, for single items, it has to be ->pagefiles->path. At least this is what I have experienced. Not sure if I am doing something wrong
  7. I have the same problem. I can confirm it is not really a bug but unwanted behavior @ryan. It occurs, that when you delete pages and create ones (with the same name? in the same run, there is a problem with the correct page to be found. As the page still exists. Is there a way to delete a page not after the entire page call is done? I supposed there is some smart mechanism to make only one SQL query, instead of synchronously deleting pages. Thanks in advance. Right now, I have to resort to two page calls.
  8. If you haven't given #BEM a chance yet as #CSS architecture, I recommend this article https://t.co/BCR5ErmmFT by @sitepointdotcom :)

  9. I "fixed" it. I created a module that loads the pageTypes for me. <? public function init() { $this->addHookBefore('ProcessPageView::execute', $this, 'loadPageTypes'); } public function loadPageTypes($event) { require_once('site/templates/classes/PageTypes/Event.php'); } This makes the Page, when loaded by ProcessPageView, also available, and thus gets assigned the correct PageClass. Phew! I am not sure this is the best solution. Right now, it is all I have to fix it. Please let me know if there is a better way. What if I want to create a Composer/ProcessWire module with the pagetypes?
  10. I found the cause, but I don't know how to fix it. I think the Event.php Page class has to be loaded before PagesLoader checks for wireClassExists($template->pageClass). How should I go about that? If I package it as module, will it be loaded before the check? I am using Composer for my profile/theme and I autoload my pageTypes using psr-4. I guess the check comes before any _init.php is loaded. Somehow, there must be a possibility to hook into the render method to load the custom pagetypes before checking for wireClassExists in the PagesLoader.
  11. Hello! I started to implement this tutorial today. I am a little stuck with the advanced options. If I load a page, it is not of type Event, but if I get - for example - the next page, it is of type Event. It is always the loaded page, that is not of type Event, but of type Page. I think this is a bug in Processwire. To give you a better overview, this is what my events pages look like: Template, test-event and Another Event are all of template event. This is my Events PageType <?php namespace ProcessWire; class Events extends PagesType { public function __construct(ProcessWire $wire, $templates = array(), $parents = array()) { parent::__construct($wire, $templates, $parents); // Make sure we always include the event template and /events/ parent page $this->addTemplates("event"); $this->addParents($this->pages->get("/events/")); $this->setPageClass('Event'); } } As explained in the guide, I also set wire->events: <? // in _init.php $events = new Events($this->wire); $this->wire('events', $events, true); This is the Event page: <?php namespace ProcessWire; class Event extends Page { public function __construct(Template $tpl = null) { if(is_null($tpl)) { $this->template = $this->wire('templates')->get('event'); } if(!$this->parent_id) $this->set('parent_id', $this->wire->pages->get('/events/')->id); parent::__construct($tpl); } Both pages are included and the Event is set as the event templates system pageclass field: Now in the _init.php I debug the $events variable and try to access the methods in the Event class. <? \TD::dump($events->find('template=event')); foreach ($events->find('template=event') as $e) { \TD::dump($e->title); \TD::dump($e); } In the events homepage, this looks like this: So far so good! Now on a subpage, The opened eventpage, is all of a sudden of type Page! I also dump the page object in the event.php template. Do you have any ideas what I'm doing wrong? Thank you a lot in advance! Best, Martin
  12. Hello! When I create a custom pagetype by extending the Page class, as explained in the guides, all works good so far. However, if I want to get data of that page (like its children, etc) the data only seems to be initialized after calling a method. <?php namespace ProcessWire; class Event extends Page { public $registrations; public $items; public function __construct(Template $tpl = null) { parent::__construct($tpl); if(is_null($tpl)) { $this->template = $this->wire('templates')->get('event'); } if(!$this->parent_id) $this->set('parent_id', $this->wire->pages->get('/events/')); // is null? $this->registrations = $this->get('template=event-registrations'); } public function register() { $this->get('template=event-registrations'); // is different from $this->registrations } } So in __construct, there is no access to the page objects data, like title etc. But when I call a function such as $event->register, I get the proper data. So my question is, is there a way to initialize that data, without retrieving all the data only after I call the method? Or do I need to hook all methods and then do the data initializing? I think alternatively I could create a getRegistrations() function and call that in every other method where I need the registrations. Any ideas? Thank you in advance!
  13. Hi there @bernhard. This totally makes sense I didn't think about that I can already use the $user-> methods in this context. Awesome! I got tracy debugger installed, I just have to bring myself to use it more often Thank you a lot for the help, it is very much appreciated.
  14. @duckduckgo Do you have any plans to make the new bang suggestion process transparent? I can't even see if someone has already suggested it.

  15. Dear #javascript. Today I found out, that instead of blaming the back-end, I need to pass the credentials option for fetch to send cookies.

×
×
  • Create New...