Martin Muzatko

Members
  • Content count

    47
  • Joined

  • Last visited

Community Reputation

21 Excellent

About Martin Muzatko

  • Rank
    Jr. Member

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

2,717 profile views
  1. 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
  2. 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.
  3. 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
  4. 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.
  5. If you haven't given #BEM a chance yet as #CSS architecture, I recommend this article https://t.co/BCR5ErmmFT by @sitepointdotcom :)

  6. 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?
  7. 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.
  8. 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
  9. 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!
  10. 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.
  11. @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.

  12. 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.

  13. Sure! no problem. I'll look into it Thank you a lot for the positive feedback.
  14. Weird! My image field is set to always return only a single item or none. I still get Pageimages in some cases, Pageimage in other cases. Weird is that I am always trying to get the image of the same object.
  15. Hello! I started to extend my user using a new class. All works fine, I am a little unfamiliar with the $event system, (Why can't we just have usual return values? This would make exiting a function at the right time a lot easier. Also plain function arguments would let me allow to better understand how to pass the $event to other functions) but it works. Now I want to re-use existing functions in other functions of the same class and it just does not work. The other functions in the same class are not callable and have - you guessed it - no return values. public function init() { $this->addHook('User::getMessages', $this, 'getMessages'); $this->addHook('User::getMessagesBySender', $this, 'getMessagesBySender'); } public function getMessages($event) { $user = $event->object; $event->return = $this->pages->find('template=message, receiver='.$user); } public function getMessagesBySender($event) { $user = $event->object; $sender = $event->arguments[0]; $event->return = $this->getMessages($event)->find('sender='.$sender); } What can I do to get the return values of other hooked methods? If I var_dump($this->getMessages($event)); I get NULL. How should I go about this? Are there maybe better methods of extending the user class in 2017? As you can see, getMessages is both a function I want to re-use, but also a hooked function. Thank you in advance!