
Xonox
Members-
Posts
95 -
Joined
-
Last visited
Everything posted by Xonox
-
Developing, I must keep deleting the assets/cache/FileCompiler folder
Xonox replied to Xonox's topic in General Support
Tried this. No change! -
Developing, I must keep deleting the assets/cache/FileCompiler folder
Xonox replied to Xonox's topic in General Support
Tried this, but it doesn't make a difference! -
Hi, On some of the sites that I develop, I must keep deleting assets/cache/FileCompiler folder in order to see the changes made in the php files. I have cache disabled for the template, but it doesn't seem matter. As you might imagine, this extra step is costly in dev time. Usually this happens in just some pages and not in other. Am I missing something? Thanks,
-
Solved it!!!! It isn't namespaces, thanks for the suggestion! It was the freaking cache!!!! It gets me everytime! Emptied the cache and it's working
-
Hi, Great script. I managed to create my own form to submit Comments. It's working great on my local dev server, however, when I put it online, I get a Class Comment Not Found for the line: $c = new Comment(); Everything is configured the same way on both sides. I added the comments field to the template. What am I missing?
-
[Solved] Page Tree giving an error (doesn't work) PW 3.0.39
Xonox replied to Xonox's topic in General Support
Hi, @Robin S, after turning on the debug mode, it was all looking fine. @Macrura, when I was looking for the directories' permissions, I came across a post that recommended to delete the cache folders, so I did and everything was working fine. Thank's guys, for sending me through the right path! I also skipped this step on my local server so it´s a bit strange that this would have any influence. But it did. Solution Delete the session and cache files in the /site/assets directory. -
Hi, I updated a site from version 2. something, can't recall for sure, to version 3.0.39. All is working fine on local server. However, when I uploaded to online server, the page tree display stopped working. 1. Whenever I try to access the page tree it gives an alert with the text: Uknown error, please try again later On the console I can see the following: GET http://mysite.com/admin/page/list?id=1&renderJSON&start=0&open=undefined&mode=actions 500 (Internal Server Error) JqueryCore.js?v=1478723146:2 2. Whenever I try to access the page children (when editing a page) it gives an alert with the text: Uknown error, please try again later On the console I can see the following: Failed to load resource: the server responded with a status 500 http://mysite.com/admin/page/list?id=1040&renderJSON&start=0&lang=0&open=undefined&mode=actions (Internal Server Error) When I was updating, I got an error on the site config.php file. I forgot to update the $config->httpHosts for the domain in the new server, which was corrected after the update. The server is running PHP 5.4, MySQL 5.5.52, PW updated to 3.0.39 Any clues?
-
Hi SamC, Sorry for the delayed answer. I still haven't been able to correct this situation. I catch these errors in the Javascript console, when I finish cropping. It gives the error on line 1 Were you able to solve your problem?
-
Hi, I can't seem to be able to crop an image in the backend. I'm using PW 3.0.29 in Chrome without Image plugins. When I click apply, the button stays on "Saving..." forever. I get the following JavaScript Errors: An invalid form control with name='width' is not focusable. ?id=1024&file=1024,cfaf-2013-poster.jpg&rte=0&field=poster&modal=1:1 An invalid form control with name='height' is not focusable. ?id=1024&file=1024,cfaf-2013-poster.jpg&rte=0&field=poster&modal=1:1 Is this a bug?
-
After some testing I came to the conclusion that we don't need the AJAX code. In fact it makes the code incompatible with the other extra actions. At the end of the day, the code becomes even simpler! It's been edited to show the final, simpler version.
-
With return via $event->return, the module stops working. The used return is inside the Ajax process, not the hook. If we change the return, the module doesn't get an ajax response and doesn't update the page (keeps the ajax spinner forever). However, I'm not that knowledgeable in ProcessWire. Does this make sense?
-
Added Custom Action but it doesn't do nothing!
Xonox replied to Xonox's topic in Module/Plugin Development
Hi all, After a lot of searching and experimenting I came up with a working solution. If someone else is looking for something like this, you can check it out here: -
I couldn't get @LostKobrakai's blueprint to work. I putted together some of @LostKobrakai code with some investigated source code from ProcessWire. Here's a full working solution: <?php class PayActions extends Process { public static function getModuleInfo() { return array( 'title' => __('Quick Pay/Unpay Method', __FILE__), 'summary' => __('Adds Pay/Unpay actions to pages that use reservation template.', __FILE__), 'version' => 102, 'singular' => true, 'autoload' => 'template=admin', ); } // MODULE INITIALIZATION public function ready() { // Default actions can't use AJAX // $this->addHookAfter("ProcessPageListActions::getActions", $this, 'hookPageListActions'); // Use Extra Actions if you need AJAX $this->addHookAfter('ProcessPageListActions::getExtraActions', $this, 'hookPageListActions'); $this->addHookAfter('ProcessPageListActions::processAction', $this, 'hookProcessExtraAction'); } // ADD ACTIONS public function hookPageListActions(HookEvent $event) { $page = $event->arguments[0]; $actions = array(); // Apply only to reservation pages if($page->template == 'reservation') { if($page->reservation_paid) { $actions['unpay'] = array( 'cn' => 'Unpay', 'name' => 'Unpay', 'url' => $this->config->urls->admin . "page/?action=unpay&id={$page->id}", 'ajax' => true, ); } else { $actions['pay'] = array( 'cn' => 'Pay', 'name' => 'Pay', 'url' => $this->config->urls->admin . "page/?action=pay&id={$page->id}", 'ajax' => true, ); } } if(count($actions)) $event->return = $actions + $event->return; } // PREPARE ACTION public function hookProcessExtraAction(HookEvent $event) { $page = $event->arguments(0); $action = $event->arguments(1); $success = false; switch($action) { case 'pay': $page->setAndSave('reservation_paid', 1); $success = true; $message = $this->_('Paid'); break; case 'unpay': $page->setAndSave('reservation_paid', 0); $success = true; $message = $this->_('Unpaid'); break; default: $message = $this->_('Failed'); } // If this action was successfull return result if($success) { $result = array( 'action' => $action, 'success' => $success, 'message' => $message, 'page' => $page->id, 'updateItem' => $page->id, 'remove' => false, 'refreshChildren' => false, ); $event->return = $result; } } } What this module does: For each page with the template "reservation" you're able to mark it as "Payed" or "Unpayed" without having to edit it:
-
Hi @LostKobrakai, I'm trying to get a custom action to work, based on this code, but I'm having some difficulties... The action label appears in the page list tree, with the right link and action, but when I click it, instead of executing the action, it just displays the single page in tree view. It seems that the action is getting ignored, some how. In the Debug Tools, it seems that the right function is being called: $this->addHookBefore('ProcessPageListActions::processAction', $this, 'executeActions'); But nothing happens. Any ideas? Thanks.
-
Added Custom Action but it doesn't do nothing!
Xonox replied to Xonox's topic in Module/Plugin Development
Update I managed to simplify the code to the minimum. I don't find any problem r why isn't working. Can someone shed some light on why the actions is not running through AJAX? <?php class PayActions extends WireData implements Module { // MODULE INFO public static function getModuleInfo() { return array( 'title' => 'Quick Pay Method', 'version' => 1, 'summary' => 'Adds Pay/Unpay actions to pages with reservation template.', 'singular' => true, // Limit the module to a single instance 'autoload' => true, // Load the module with every call to ProcessWire ); } // MODULE INITIALIZATION public function ready() { $process = wire('page')->process; if($process == 'ProcessPageList') { // Use getPageActions because I don't want to place in the extra (expandable) actions $this->addHookAfter('ProcessPageListRender::getPageActions', $this, 'addPageListActions'); // Hook to the page actions $this->addHookBefore('ProcessPageListActions::processAction', $this, 'executeActions'); } } // ADD ACTIONS public function addPageListActions(HookEvent $event) { // Initialize $page = $event->arguments[0]; $actions = array(); $actions = $event->return; // Apply only to reservation pages if($page->template != 'reservation') return $actions; if($page->reservation_paid) { $actions[] = array( 'cn' => 'Unpay', 'name' => 'Unpay', 'url' => $this->config->urls->admin . "page/?action=unpay&id={$page->id}", 'ajax' => true, ); } else { $actions[] = array( 'cn' => 'Pay', 'name' => 'Pay', 'url' => $this->config->urls->admin . "page/?action=pay&id={$page->id}", 'ajax' => true, ); } $event->return = $actions; } // EXECUTE ACTION public function executeActions($event) { if(isset($actions[$action]) && $page->editable()) { $success = true; $needSave = true; $message = ''; $remove = false; $refreshChildren = 0; switch($action) { case 'pay': $page->set('reservation_paid', 1); $message = $this->_('Paid'); break; case 'unpay': $page->set('reservation_paid', 0); $message = $this->_('Unpaid'); break; default: $success = false; $action = 'unknown'; } // Save page or catch errors if($success) try { if($needSave) $success = $page->save(); if(!$success) $message = sprintf($this->_('Error executing: %s', $message)); } catch(Exception $e) { $success = false; $message = $e->getMessage(); } } else { $success = false; } $result = array( 'action' => $action, 'success' => $success, 'message' => $message, 'updateItem' => $page->id, // id of page to update in output 'remove' => $remove, 'refreshChildren' => $refreshChildren, // also available: 'appendItem' => $page->id, which adds a new item below the existing ); return $result; } } -
Hi, This is my first module development and I have a couple of questions. First to explain the objective of the module. I want to set the site reservations (Pages with reservation template) as Payed or Not Payed, straight from the Page Tree View. So far, I was able to display the actions as I wanted, but can't do nothing. I was to build through a couple of posts I checked but there are some things that aren't working: 1. The action is running but it's not working: switch($action){ case 'pay': $page->reservation_paid = 1; $page->save; $success = true; $message = 'Payment done!'; break; case 'unpay': $page->reservation_paid = 0; $page->save; $success = true; $message = 'Payment removed!'; break; } 2. How can I make sure that it runs as ajax and updates the page? As you can see ajax is set to true but it doesn't seem to be working. 3. Do I need the protected function createActions($page)? Doesn't seems to be doing nothing. Here's the full code. If someone could give me some insights, it would be greately appreciated. Thanks, <?php class CustomActions extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Custom Actions to Page List', 'version' => 1, 'summary' => 'Adds Custom PageActions to Page List actions', 'singular' => true, // Limit the module to a single instance 'autoload' => true, // Load the module with every call to ProcessWire ); } public function init() { $this->addHookAfter('ProcessPageListActions::getExtraActions', $this, 'addActions'); $this->addHookBefore('ProcessPageListActions::processAction', $this, 'exeActions'); } /** * Add the new actions */ public function addActions($event) { $page = $event->arguments[0]; $actions = $event->return; // We do not overwrite existing core actions $actions = array_merge($this->createActions($page), $actions); // $event->return = $actions // Shouldn't be needed } public function ready() { $process = wire('page')->process; if($process == 'ProcessPageList') { $this->addHookAfter("ProcessPageListRender::getPageActions", $this, 'hookPageListActions'); } } public function hookPageListActions(HookEvent $event) { $actions = array(); $page = $event->arguments[0]; // Apply only to reservation pages if($page->template != 'reservation') return $actions; $actions = $event->return; if($page->reservation_paid) { $actions[] = array( 'cn' => 'Unpay', 'name' => 'Unpay', 'url' => $this->config->urls->admin . "page/?action=unpay&id={$page->id}", 'ajax' => true, ); } else { $actions[] = array( 'cn' => 'Pay', 'name' => 'Pay', 'url' => $this->config->urls->admin . "page/?action=pay&id={$page->id}", 'ajax' => true, ); } $event->return = $actions; } /** * Create the actions */ protected function createActions($page){ $actions = array(); if($page->template != 'reservation') return $actions; //if($page->template->noSettings || !$page->editable('status', false)) return $actions; $adminUrl = $this->wire('config')->urls->admin . 'page/'; if($this->wire('user')->hasPermission('page-edit', $page) && !$page->isTrash()) { $actions['page-edit'] = array( 'cn' => 'Pay', 'name' => 'Pay', 'url' => "$adminUrl?action=PageActionPay1&id=$page->id", 'ajax' => true, ); } return $actions; } /** * This is run when an action is initiated * * This can only been called if a page is editable. */ public function exeActions($event) { list($page, $action) = $event->arguments; $actions = $this->createActions($page); // This way checking for roles or other access rules is not duplicated. // If the action is still created, it's also actionable. if(!isset($actions[$action]) || !$page->editable()) return; $success = false; $needSave = true; $message = ''; $remove = false; $refreshChildren = 0; switch($action){ case 'pay': $page->reservation_paid = 1; $page->save; $success = true; $message = 'Payment done!'; break; case 'unpay': $page->reservation_paid = 0; $page->save; $success = true; $message = 'Payment removed!'; break; } // Return if success, otherwise move on to the hook function if(!$success) return; else $event->replace = true; // Return information $event->return = array( 'action' => $action, 'success' => true, // Fails are managed later by hooked function 'message' => $message, 'updateItem' => $page->id, // id of page to update in output 'remove' => $remove, 'refreshChildren' => $refreshChildren, // also available: 'appendItem' => $page->id, which adds a new item below the existing ); } }
-
I decided to reinstall XAMPP all over again, and all the sites started to load faster. However I removed all the databases that I had before (about 100). I can't really tell why, but to me, it seems that MySQL was the culprit. One thing that was happening, which was weird: Every time I refreshed the slow site, Apache would open a new port. It came to a situation that i had dozens of ports opened for Apache, instead of just 80 and 443. This was what made me reinstall XAMPP all over again. However, sometimes, in the production server, the sites becomes really slow which means that I'm not out of the woods, yet. In the tests I made, the slowing down is caused in the server because the page takes about 20 to 30 sec. to be received, but then, all the elements take a couple of ms. So I believe that it is some processing or dbase access that is taking too long. When I call my service provider, they always say everything is ok. However, in the production site I only have one active database. An other thing that might be related: The admin users tell me that sometimes, when they try to crop a large image, the site keeps them waiting for ever without managing to succeed the crop. Might it be related to image processing? Third party modules: - Email Obfuscator - Fieldtype Time - Upgrades Checker I turned on the cache for some of the most demanding pages. Thanks pwired, I was looking for a tool that would give me some insight on MySQL performance, monoyog looks perfect for it.
-
There's no unusual process consumption. It appears like I have 2 apache services. I'm already using 127.0.0.1 I have several ProcessWire installations that are working. This one in question seems way off, for some reason.
-
It seems the problem lies in the line 232, in index.php: $wire = new ProcessWire($config); If kill the process before this line, everything is quite fast. When trying to create $wire, it hangs.
-
Now it seems like it's a matter of time. After I restarted the computer, everything was running fine. After calling some pages and improving some code, it all started to crumble. To the point where I can't even get a "Maximum execution time of 30s exceeded" it just keeps waiting. I'll keep digging.
-
Yes, I have. Done that! To no avail! Meanwhile my website improved a little by not calling renderNavTree in some files. Is there any problem with this function?
-
Hello, I've searched high and low and this came to a point where there's not much I can do. I'm simply unable to view the site, now. So far: 1. index.html - HTML file is fast, so it's not an apache problem. 2. text.php - A simple php showing php info is fast, so it's not a PHP problem. The site has been becoming slower and slower over time. I installed xdebug and I get the results you can see in the attached images. I'm concerned because this is a problem that is getting worse, and worse, and worse. To the point to which is impossible to keep working in the website. Any ideas of what I might do to improve this situation. It's getting real bad in the site and also on the backend. Thanks...
-
Bootstrapping ProcessWire gives an error on image resize???
Xonox replied to Xonox's topic in General Support
It worked flawlessly... thanks for explaining so clearly all it's possible to do with ProcessWire. -
Bootstrapping ProcessWire gives an error on image resize???
Xonox replied to Xonox's topic in General Support
Thanks: @teppo, @LostKobrakai You were both right. By changing: $event_image = $newsletter->newsletter_events[0]->event_cover->size(550, 260); Into: $event_image = $newsletter->newsletter_events[0]->event_cover->first()->size(550, 260); It worked! However it stopped working when visualizing through the template file. I know I could make some kind of condition to use one or the other but is there any kind of best practices, so that this works in both scenarios and the code is clean? -
Bootstrapping ProcessWire gives an error on image resize???
Xonox replied to Xonox's topic in General Support
For this field in particular, only one image is allowed (and required). Here's the code I'm using: <?php ... $newsletters = $pages->get('/newsletters/')->find("template=newsletter, !newsletter_sent=1, newsletter_date<=$now"); if(isset($newsletter->newsletter_events[0])) { $event_image = $newsletter->newsletter_events[0]->event_cover->size(550, 260); echo $newsletter->newsletter_events[0]->title; ... When I comment the $event_image line, the event title is echoed, so the event is recognized. A couple of things I forgot to mention: When using a template file (without bootstrapping ProcessWire) it works fine. I'm outputting the result through ob_get_contents, in order to process all the HTML into a variable. ob_get_contents code: <?php ob_start(); include($newsletter_template_file); $newsletter_content = ob_get_contents(); ob_end_clean(); Do you think it might be a problem related to the ob_get_contents?