Jump to content

Search the Community

Showing results for tags 'hook'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello, I am still learning ProcessWire. I am trying to hook a method in ListProConfig.php. After the processInput method is called I would like to know the user id of the person that called the method, the page name that was involved in changed lister settings, and then get the new settings. I am having problems getting my hook to work. In the init of my module I have the following code: wire()->addHook("ListerProConfig::processInput", function($event){ $this->wire('log')->save('stephen_ext',"Someone called processInput"); }); Even though I know that processInput is called I never get anything written to my log.
  2. How can I change the output of `Page::render`? I've created a hook before page::render, but when I set the $event->return to something else, my whole page is replaced with that value. For example: public function beforePageRender(HookEvent $event) { $event->return = 'blaat'; } This will cause my whole page to be nothing more than just 'blaat'. What I want, is that my menu, footer etc. are still visible but only the content of that page is replaced.
  3. Hi, I have a method (___renderImage) which renders an image tag (<img src) and has a single argument: Pageimage $image. Now I have a hook called "beforeRenderImage" in which I'd like to add a property to the argument of ___renderImage. So for example, I'd like to add a property "requiredDimension" to the argument before ___renderImage is called. Is this possible?
  4. I've added a hook after the '"ProcessPageEdit::buildFormContent" event. I've added a new config option to the language settings: public function beforeAdminProcessPageEditBuildFormContent (HookEvent $event) { $editPage = $this->getPage(wire('input')->get('id')); if ($editPage->template->name == 'language') { // only add field when editing language page $field = wire('modules')->get('InputfieldText'); $field->attr('name+id', 'locale'); $field->label = __('Locale'); $event->return->insertAfter($field, $event->return->getChildByName('title')); } } I've also created a field (Setup > Fields > Add new) which I've also named 'locale'. The field is displayed, but the value isn't saved when I click the save button. How do I make sure the input of the field is saved as well? And how can I access the stored value once it's saved?
  5. Hello, for quite a while I found it quite annoying that when you edit a page from a lister view and then save+exit you will end up at the page tree and not at the lister view where you came from. I haven't found a setting that lets you return to the lister view. I wrote a little hook that does just that for a project where I am using Lister Pro. The lister is called Events and has a fixed url. It lists only one type of pages with template event. Here's the working hook code that I placed in admin.php: // redirect to events list on save+exit wire()->addHookBefore('ProcessPageEdit::processSaveRedirect', function($event) { $id = (int) $this->input->post('id'); $page = wire('pages')->get($id); if($this->input->post('submit_save') == 'exit' && $page->template->name == 'event' && wire('user')->hasRole('member')) $this->session->redirect(wire('config')->urls->admin . 'events/'); }); Now I would like to make this more generic so that it works for any lister. How can I get the referring URL (other than from $_SERVER['HTTP_REFERER']) to use it instead of the hardcoded URL I have now in the redirect? And is there any way that I can access properties of the instance of ProcessPageEdit that called processSaveRedirect? The $event->object is the processSaveRedirect method and $this is ProcessWire. How can I access properties of ProcessPageEdit? E.g. $id or $page. ATM I am getting the page id from the $input->post. Obviously I am not a savvy PHP OOP dev and have no idea how to do such things in a proper way EDIT: I know I could open pages from the lister view in a modal to avoid having to redirect. But I don't want to use that option. $_SERVER['HTTP_REFERER'] gives me the URL of the page that I edited and not the URL of the lister.
  6. Hello, I'm trying to hide a specific field with a hook. This is what I tried so far. Changing the field label works but the hiding not. Changing addHookBefore to addHookAfter makes no difference. I searched the forum and found similar thread but could not translate the answer to this situation. Any help would be appreciated. class HideFields extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Hide Fields', 'version' => 100, 'summary' => 'Hide fields', 'singular' => true, 'autoload' => "template=admin" ); } public function init() { $this->addHookBefore('Inputfield::render', $this, 'setHide'); } public function setHide($event) { $inputfield = $event->object; if($inputfield->name != "Foo") return; $inputfield->label = "Bar"; // This works $inputfield->collapsed = Inputfield::collapsedHidden; // This doesn't work } }
  7. How would one pass a variable set in one module to another module via a Hook? e.g. module 1. public function ___saveUser($vars){ $userSaved = true } module 2 public function init() { $this->addHookAfter('module1::saveUser', $this, 'userSaved'); } public function userSaved($e){ $userSaved = $e->userSaved; return $userSaved; // true? }
  8. Hey, I made a hook that is triggered when a page with a certain template is saved. I meant to create the script only for the backend of the website. Now, whenever a page is saved on the front end (with the API) the module is being triggered. I was wondering if there is a method to have it only trigger whenever a page is saved on the backend (so not through the API). Jim
  9. Hi I have an image field in the back end, that expects multiple images. Now I've added this hook as the files are added: $page->addHookAfter('InputfieldFile::fileAdded', function($event) { $inputfield = $event->object; wire('log')->save('image-resizing', "Resizing "); $image = $event->argumentsByName("pagefile"); $image->size(800,0,array('upscaling' => false)); $image->size(300,200,array('cropping' => true, 'quality' => 80 )); }); It works absolutely fine for a small amount of images, but uploading a large amount doesn't seem to work. No errors are logged either. Now all thes photos appear to have uploaded in the back end, and show the thumbnails, but upon clicking save images are missing. I've checked all my php settings and ensured they are all adequate enough. memory_limit 512mb upload_max_filesize 200mb max_execution_time 300 If I disable this hook, I can upload all images fine. Please could anyone other any insight into what may be causing this issue? Thanks in advance
  10. Folks, I may have discovered a) a bug or b) that I can't write code for shit. I have this hook setup: $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments(0); $repeater = $page->collections_detail_images; foreach ($repeater as $row) { $row->of(false); $row->collections_detail_image_page_title = $page->title; $row->collections_detail_image_page_type = $page->collections_detail_category->name; $row->collections_detail_image_page_pattern = $page->collections_detail_pattern->name; $row->collections_detail_image_page_designer = $page->collections_detail_designer->name; $row->setAndSave(); } }); For each repeater row on a page I am editing, upon save, it fills in the desired fields with content required. This all works well, however, the issue/bug is this... Each repeater row also has an image field (limited to 1), which I have been dragging and dropping an image to, for each row in the repeater, then saving. I tend to add 5-10+ rows (each with an image) at once then save. This is where the issue occurs. Even though it looks like the image is there and saved... it's not appearing on the front-end. If I do one row at a time and save, it works fine, it's only if I do 2 or more in one 'save session'. This only happens with drag and drop too. If I remove my hook, shown above, I don't seem to get any issue. Any thoughts?
  11. I'm curious to know if this is possible. I'd like to write a hook that upon adding an image to a specific page it will rename the image to the name of the page it's been/being uploaded to? I have a bank of images all with really useless filenames but would like to sort this upon uploading each one. Each image is added in a repeater with a corresponding colour (Pagefield), for example: I wonder if I could write a hook that would take each image in the repeater and rename each one something like pagetitle_01_charcoal pagetitle_02_red What do you think? Is it possible to write a hook to change a filename? Either on save or as it's uploading? Any advice/help is appreciated.
  12. Hi everybody, im planning to release an updated version of the TwigReplace module for ProcessWire 3. In addition to the known config options for setting up the twig environment, I'm wantg to provide the means to enable twig extensions at will. But this can't be done via module config options because of different reasons (finding the correct twig extenion classes - installed or self-made, providing constructor arguments to the twig extension, ...). To solve this I plan to add a hookable method to my module that instantiates and returns the Twig_Environment object. If this works, users of the module may create their own project specific modules to intercept this hook and modify the Twig_Environment instance by adding twig extensions at will. Here's the skeleton of my module (with ___initTwig() being the hookable method): namespace nw\ProcessWire3; use ProcessWire\FileCompilerModule; class FileCompilerTwig extends FileCompilerModule { /** * @var \Twig_Environment */ protected $twig; /** * Creates the twig render engine if necessary */ public function init() { /* * gather module config settings ... */ $this->twig = $this->initTwig($pwTemplatesPath, $twigOptions); } /** * Instantiates a Twig environment * * THIS IS THE HOOKABLE METHOD. * * @param string $pwTemplatesPath * @param array $twigOptions * @return \Twig_Environment */ public function ___initTwig($pwTemplatesPath, array $twigOptions) { $loader = new \Twig_Loader_Filesystem($pwTemplatesPath); return new \Twig_Environment($loader, $twigOptions); } This works fine so far. But when I try to hook into the ___initTwig method via another module, nothing happens. Now I'm not sure if the entire concept (hooking into a module from another module) isn't supported by ProcessWire, or if I just haven't found the correct way to address the desired hook (maybe due to namespacing issues). So far I tried: namespace nw\ProcessWire3; use ProcessWire\HookEvent; use ProcessWire\Module; use ProcessWire\WireData; class FileCompilerTwigExtensions extends WireData implements Module { public function init() { $this->addHookAfter('FileCompilerTwig::initTwig', $this, 'addTwigExtensions'); // didn't work either // $this->addHookAfter('nw\ProcessWire3\FileCompilerTwig::initTwig', $this, 'addTwigExtensions'); // $this->addHookAfter('\nw\ProcessWire3\FileCompilerTwig::initTwig', $this, 'addTwigExtensions'); } public function addTwigExtensions(HookEvent $event) { /** @var \Twig_Environment $twigEnv */ $twigEnv = $event->return; $twigEnv->addExtension(new \Twig_Extension_Debug()); } } I'm thankful for any suggestions. wumbo
  13. Hello everyone! I'm not sure the right thread is chosen, but anyway I'll continue. My pages structure looks like Category->Subcategories->Pages A task is to make PW to count Pages,when their amount is changed and write it to the Subcategory's and Category's appropriate field regardless of Pages amount change is made from admin of template. So I'm trying to hook into 'save', 'trash', 'restore' and 'delete' methods from within a site module. 'Save' hook seems to work fine, but hooking into 'trash' requires to track Page->parent and Page->parent->parent the the other way, because they are changed to 'Trash' and 'Root' when 'trash' execution is is finished. The other words, at the moment when I have to count Pages in Category and Subcategory, where the Page was 'thrashed' from, there is already no way to determine, what the Category and Subcategory contained this Page. I'm trying to hook into 'trash' before execution, find Page Category and Subcategory and assign them to an module object property, so after the 'trash' execution I can hook into it again and count Pages in Category and Subcategory, saved in properties. But something causes my before 'trash' hook to execute two times: before and after 'trash', and as the result module object properties contain not Category and Subcategory, but 'Trash' and 'Root' pages. Here is my Code: public $country; public $region; /** * Initialize the module * */ public function init() { $this->pages->addHookBefore('trash', $this, 'prepareTripSave'); $this->pages->addHookAfter('trashed', $this, 'afterTrash'); } /** * Counts 'Trips' in 'Region' and 'Country' * */ public function countTrips($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { // do only when 'Country' and 'Region' are find if(count($this->country) && count($this->region)) { $this->message('ok'); $amount = $this->region->children("template=Trip")->count(); //count 'Trips' in 'Region' $this->region->setOutputFormatting(false); $this->region->amount = $amount; $this->region->save("amount"); // save only field $this->region->setOutputFormatting(true); $amount = $this->country->find("template=Trip")->count(); //count 'Trips' in 'Country' $this->country->setOutputFormatting(false); $this->country->amount = $amount; $this->country->save("amount"); // save only field $this->country->setOutputFormatting(true); } else { $this->message('nop'); } $this->message("Country: {$this->region->amount}; Region: {$this->country->amount}"); $this->region = ''; $this->country = ''; } } public function prepareTripSave($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->region = $this->pages->get($page->parentID); // find 'Region' by 'Trip'->parentID $this->country = $this->region->parent; // find 'Country' as a 'Region'->parent $this->message("Before Region: {$this->region->title}; Country: {$this->country->title}"); } } public function afterTrash($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->message("After Region: {$this->region->title}; Country: {$this->country->title}"); } } Thanks!
  14. Hey All. I am trying to change the label of a field after a certain page is saved. This field is not part of the page that is saved but the label should be updated with the page name. $pages->addHookAfter('saved', function($event) { $page = $event->arguments[0]; if($page->template->name == 'service-type') { $cid = $page->id; $this->message($cid); /* find field servicetype_rangeslider_$cid and set label */ // how to access $fields?? } }); I have this hook in my /site/ready.php. Now my remaining problem is, how to access $fields array or in general, how to get the field? I am thankful for every hint, thanks!!
  15. Ahoy captain! I need to hook into 2 areas of ProcessWire: - "view" page link on page tree - "view" page link on page edit (Are there more areas with these "view" links for pages or did I get everyone?) How can I hook into that in order to change the "view" link url? Arrr! It would be great if someone would help me with that! – Pirate GlassedEyes
  16. I have a simple module that creates a page when another page is saved with a checkbox field checked. My code below works well but I have one issue, it runs when the page is trashed as well as saved (creating an erroneous second duplication of the page). <? public function init() { $this->pages->addHookAfter('save', $this, 'dupeStandalone'); } public function dupeStandalone($event) { $page = $event->arguments[0]; if($page->template->name == "article_language" && $page->article_standalone == 1) { $a = new Page(); $a->template = 'article_standalone'; $a->parent = wire('pages')->get('/article/'); $a->name = $page->name; $a->title = "{$page->title} (standalone placeholder post for {$page->parent->parent->title}-only article)"; $a->save(); } } Could anyone help as to why it runs the function on trash as well as save?
  17. Hello, I am trying to get the cleartext password in a hook on saveReady in an autoload module. But I get the already hashed value of the password: Session: pass: L1/CERxHKqXJCJkogk89O48b4bMnsqW What I have protected $templates = ["user", "server"]; public function init() { $this->pages->addHookAfter('saveReady', $this, 'hookSaveReady'); } public function hookSaveReady(HookEvent $event) { $page = $event->arguments[0]; if($page->isNew) return; if(!in_array($page->template, $this->templates)) return; if($page instanceof User) $this->collectUserData($page); } public function collectUserData($page) { foreach ($page->fields as $field) { /*if( $page->isChanged($field) ) */$this->message($field->name . ": " . $page->$field); } } I guess I am hooking too late in the process but have no idea where to place the hook instead. EDIT: same with addHookBefore
  18. I need some help. I have fields price and priceBefore I want to copy price value on save to priceBefore field. public function init() { $this->pages->addHookAfter('save', $this, 'hookSave'); //$this->pages->addHookAfter('added', $this, 'hookAdded'); } public function hookSave(HookEvent $event) { // this function called any time a page is saved (whether new or not) //$page = $event->object; $page = $event->arguments[0]; // now you can access anything from the $page if ($page->template == "nepremicnine-vnos") { // get value from price field and copy to priceBefore/cenaStara $page->cenaStara = $page->cena; $page->save("cenaStara"); } } I 've read some examples but I just can't make it work. Is it maybe better to put it in InputField::render? public function init() { // add before-hook to the inputfield render method $this->addHookBefore("Inputfield::render", $this, "renderField"); } public function renderField(HookEvent $event) { // // get the current field $field = $event->object; if($field->name == 'cenaStara' && $field->value == '' ) { $field->cenaStara = $field->cena; $oldPrice = $field->cenaStara $field->set('value', $oldPrice); } }
  19. I need to save order for elements in global tree after using "page" fieldtype in other page. It's better to look on image attacheted to understand. I wish to know the better and easiest way to solve it or <code> example ! Thanks
  20. I'm trying to modify the property 'path' for a specific Page (User, actually) using the following code: $this->addHookAfter("Page::path",$this,"modifyUserPagePath"); AND public function modifyUserPagePath(HookEvent $event){ $p = $event->object; if($p->template == "user" && $p->hasRole("ambassador")){ die("MODIFY THE PATH HERE WITH PREFIX FOR THE CURRENT VIEWING PAGE"); } } But i'm not able to retrieve the page that is currently running (as in, the page in the browser url). Please note I'm also using the render() method to render subpages content. I don't need the subpages url but only the original $page requested. Is there a pretty way to do this (besides looking it up via $_SERVER['REQUEST_URI'] )?
  21. Hello fellow wirecionados, looking at the roadmap to 3.0 always gives me the good feeling of being on the sunny, futureproof side when using Processwire. Everything we already have together with the features planned is all I ever needed from a CMS. At least this is what I thought until that next idea came to my mind. Actually, there's one thing about Processwire that I have been struggling with from the start and until now: the hook system. I know, the hook system is deeply enrooted in Processwire (as can be seen from the fact that it's implemented in the Wire class that virtually every other class extends) and therefore is one of the key aspects for its success in the first place. It allows for the relatively loose coupling of components, with a lot of the core functionalities being implemented as modules. This makes for the great extensibility that Processwire is famous for. There aren't many parts of Processwire that can't be tweaked and modified to anyones needs by developing a module that alters some core functionality. I'm really glad about that and probably wouldn't have started to use Processwire in the first place, if the hook system didn't exist. That all being said, I also see some more or less problematic downside to the current implementation. It's sometimes pretty hard to find out, where functions are actually implemented. How long did it take you to find out that the actual logic for Page::render() is implenented in PageRender::renderPage()? While this kind of flexibility is just great, the implementation is not very verbose. This makes things harder than they have to be – especially for beginners. Just to make the argument above worse, there are several different ways to define a hook: addHook(), addHookAfter() & addHookBefore(), and all can be called either with a Class name or on an object. This makes it even harder to find modules, that hook into a particular function. I know, we have Soma's fabulous Captain Hook, and I use it all the time, but it still feels more like a workaround than like a solution. Speaking of Captain Hook, there's still a „Crocodile Hooked“ missing, a central repository that keeps track of all methods that are hooked to another method, including (private) site modules – and if possibly available at run time. Hooks for classes are saved in a static variable of Wire, but local hooks can only be fetched from that particular instance of an object. The convention with the three underscores in front of a function name makes functions harder to find. It is a nightmare to debug. If you ever tried to follow a request through the system with Xdebug, maybe involving some hooks placed by modules, you probably know what I mean. You have to go through Wire::runHooks() and __call() again and again to get where you want. It also prevents some of the convenient features of your favourite IDE™ (e.g. code completion, parameter hints when using a function, go to the definition of a function by clicking on it, etc.) from working in some cases. While one could definitely argue, that this is the fault of the IDE used, it's still slowing down work and not likely to be changed anywhere soon. Please excuse me if this was too ranty and even more correct me if anything I mentioned is an error on my side. I have to emphasize that none of these downsides prevents anyone from getting something done, it just makes it a tad less obvious and comfortable. Thinking through the things that I don't like about the current implementation of the hooks system, it came to my mind, that what we currently have here is kind of a non-verbose version of a „traditional“ event system and maybe what's missing could be more verbosity, so maybe such an event system (that implements the mediator pattern) could be of help? What I have in my mind here is the Symfony EventDispatcher or the Drupal8 EventDispatcher component, which is similiar to the CakePHP Events System and the handling of Events in Laravel. Let's look at how a solution to the problems mentioned might work by way of example using the Symfony EventDispatcher. In this particular example, the difference would be that Page::render() would actually be implemented in the Page class but just dispatches an Event.render event. Functionally no real difference, but much more verbose and therefore it is much more clear, that you will find the implementation anywhere a listener for Event.render is added. A new implementation could use just one method to add listeners (e.g. EventDispatcher::addListener()). Execution before or after an event will have to be handled by multiple events where this makes sense. Because the event dispatcher is the application-wide sole instance where event listeners are stored, it's easy to get all registered event listeners at runtime (using EventDispatcher::getListeners()). No more underscore's, just calls to dispatch events and calls to listeners. Debugging get's as smooth as it get's with loose component coupling. No more running through __call() all the time, always be able to check the defined event listeners. Having separated before and after events prevents you from some running through runHooks(). The added verbosity also helps to grasp the existing architecture quickly. Most of the IDE comfort functionality that doesn't work now should work with the Event System in place, because functions are always really where they are expected and with the exact same name. As an added benefit this system is very well known to a lot of developers already. But there are also some downsides for sure: Added verbosity is, well, verbose. More keys will have to be hit to get something done. Method and property would have to be implemented differently. This can be done by sending events on missing methods/properties, but it certainly looses some of the appeal it has now. The key argument would for sure be, that it breaks compatibility with a lot of core and user contributed modules. This is definitely true, so there shouldn't be an easy decision on this one. I thought I'll use the time before 3.0 to bring this one up, because as I understand it, the next major will break some stuff either way. Also I think that it should be possible to do the switch by in the beginning only deprecating the old hook system while keeping it functional, by translating calls to the old functions to adding and calling event listeners. This will have a performance impact, but would make a gentle transition possible. Now I'm really interested on your opinions on this topic. Do you already like the current implementation and wouldn't want to loose it? Do you have other problems with hooks? What kind of solution could you imagine? Is such a deep change realistic (and worth it) at all? Thanks a lot for your feedback Marc
  22. Hello, part of my new project is providing a RESTful webservice through PW. I am using clsource's REST Helper for ProcessWire which is working great. For the REST service part of the site I would like to suppress the setting of session cookie for $session->login and $session->logout because I don't need sessions and I don't want to have Set-Cookie in my response header. For user authentication in a PUT request I use $session->login() to verify username and password: $uId = $input->urlSegment1; $u = $users->get($uId); if ($session->login($u->name, $params["upass"])) { $session->logout(); //update user data } In the response header for that request I get: Set-Cookie: wire=ha6io723mkfc9v4scdib3oe8g7; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=1n8faeiva3vg7u13ijsrs24bt1; path=/; HttpOnly wire_challenge=YK0WRw0Wrd2ZAhKEUCLPOHd9iSySEPb91; expires=Tue, 07-Apr-2015 14:11:24 GMT; path=/; httponly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=u9m41s8b87d3ca1jp1jbl0r6k3; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=oidcbmht561qnvts2fjnq4b7p3; path=/; HttpOnly persist=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/ At the moment I get rid of it by doing header_remove("Set-Cookie"); But I would like to avoid setting of that cookie in the first place. I found the relevant methods ___login and ___logout in /wire/core/Session.php But searching Captain Hook for "logout" doesn't bring up those methods. I assume they should be hookable because they start with 3 underscores. Now how would I hook into those methods from my template file (not as an autoload module)? The webservice endpoint url is .../api/users/ and my temlate file for that is users.php What I've tried so far is wire()->addHookBefore('Session::logout', null, 'logoutNoCookie'); function logoutNoCookie($event) { $event->replace = true; $sessionName = session_name(); $_SESSION = array(); // if(isset($_COOKIE[$sessionName])) setcookie($sessionName, '', time()-42000, '/'); // if(isset($_COOKIE[$sessionName . "_challenge"])) setcookie($sessionName . "_challenge", '', time()-42000, '/'); session_destroy(); session_name($sessionName); $this->init(); session_regenerate_id(true); $_SESSION[$this->className()] = array(); $user = $this->wire('user'); $guest = $this->wire('users')->getGuestUser(); $this->wire('users')->setCurrentUser($guest); $this->trackChange('logout', $user, $guest); if($user) $this->logoutSuccess($user); $event->return = $this; } But this gives me an error: Fatal error: Using $this when not in object context because I'm placing my hook function outside the class context. What would be the correct way for calling the hook and placing my hook function?
  23. Hi! I am building a site where there is another user-template as introduced in 2.5.14. (http://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users) For now, you have to add the parents of the users with the new user-template manually like so: $config->usersPageIDs = array(29, 1026, 1027); But I have dynamically growing pages which hold the new users, like so: Home Members Group User User Group User User ... ... Ryan mentioned they're working on automating that process, but I wonder how I could accomplish this now. Naively I tried to fetch the parents like so, directly in config.php: (I'm quite novice ) $those_pages = $pages->find("template=that_template"); But that failed - nothing got rendered. Then, I thought I could do that in the site template files. But that would be too late, I guess? Also this approach would be useless for the backend... and I guess I don't need this configuration for the fronted anyway!? Now I wonder where would be the right hook to some function in the right time to accomplish this? Or any other solution? Hope you get what I mean ...
  24. Hi, i want to build a simple tracking system, where i can see how the users navigate through my site. Right now i insert a row in a custom db-table with a unique id, the page a user visits, the page the user came and a timestamp. I do this with a after-hook to »ProcessPageView:finished«, which is setup in an _init.php template which is prepend to any other template. This works fine. The problem is that this doesn't work on cached templates/pages. How can I use the template-cache-feature AND update my db-table via this hook or any other technique? Thanks!
×
×
  • Create New...