sforsman
Members-
Posts
131 -
Joined
-
Last visited
-
Days Won
5
Everything posted by sforsman
-
Hello! Without one seeing actual code, it will be very difficult to say/guess unless you narrow down the bottleneck a bit. If you don't want to give us the code, could you clock the different stages and tell us the results?
-
I am on mobile atm but when I get home I will give you the code to implement a flexible way to temporarily disable/enable the execution of the filters. I will also explain formatValue more, but yes, it is there always.
-
Pwfoo, in that case, like I have mentioned, the class will not exist until your main module's file is included, which happens only when you actually request the module (for an example with $wire->modules->get("MainModule")).
-
By the way the order does not matter if your main module is not an autoloading module. Its real class is not loaded until the module is requested in the template. You will only have a placeholder that is created based on the cache, without including the main module's code.
-
Oh, do you mean that you are just trying to see if a module is installed? And if so, you want another module to be loaded?
-
I have read it. My point is that during ProcessWire bootstrapping, the class does not exist yet, and the existence (i.e. your conditional autoloading function) won't be checked after ProcessWire becomes ready() Edit: Just to make this clear - the only thing you have when your conditional autoloading function is called is a placeholder module, the actual class hasn't been included yet - so it doesn't exist (unless it's an autoloading module or your module cache is empty). It will be included and replaced when you request the module inside your template - but like I have said, this does not trigger any conditional autoloading for other modules. There is guarantee for the conditional autoloads - they are triggered when ProcessWire goes ready().
-
After ProcessWire has finished the ready-stage, none of the conditional autoloads are evaluated again (the list of them is even cleared). This means that if you load a module in a template, you are already past the ready-stage and hence no autoloading conditionals will be processed.
-
Hello and welcome! The Hooks are meant to extend (or even replace) the functionality of ProcessWire and it's modules. They are a general concept and not something that provide features on their own. Instead you attach to them, to implement the feature you are needing. In your case, one example for their usage could be hooking into Fieldtype::formatValue and automatically filtering some specific fields when they are output in a template. I don't know how you are using the filters, so this might not be very useful. Here's a quick example anyway // Filter.module public function init() { $this->addHookAfter("FieldType::formatValue", function(HookEvent $e) { $page = $e->arguments(0); $field = $e->arguments(1); $value = $e->arguments(2); // Execute for my_field only if($field->name != "my_field") return; $e->return = applyFilter("my_field", $value); }); } // Demonstration in CLI require 'index.php'; addFilter('my_field', function($value) { return strtoupper($value); }); addFilter('my_field', function($value) { return md5($value); }); // If you are inside a template this isn't needed $page = $pages->get('/some-example-page'); $page->setOutputFormatting(true); echo $page->my_field; // Would print a MD5-hash of the uppercase version of the original value It would be quite trivial to extend this so that you could do $field = $fields->get('my_field'); $field->addFilter(function($value) { ... }); $field->addFilter(function($value) { ... });
-
Hello, Wow ok, there is so many ways to do what you are trying to do. I would have to understand your site better to be able to say what would be the most efficent way. But just to give you an idea, you could create a module that hooks the matching inmuebles as a property for the cliente-pages. I have done this by taking the big if(...) you created and turning it into a selector. public function init() { $this->addHookProperty("Page::inmuebles", function (HookEvent $e) { $page = $e->object; // We only execute for cliente-templates if($page->template->name != "cliente") return; $sanitizer = wire('sanitizer'); // Create the selector "template" $selector = "template=%s"; $selector.= ",prop_precio<=%s"; $selector.= ",prop_habitaciones>=%s"; $selector.= ",prop_tipo_inmueble=%s"; $selector.= ",prop_tipo_transaccion=%s"; $selector.= ",prop_zona=%s"; // The values $values = Array( "Inmueble", $page->prop_precio, $page->prop_habitaciones, $page->prop_tipo_inmueble, $page->prop_tipo_transaccion, $page->prop_zona, ); // Make the selector safe $selector = vsprintf( $selector, array_map(Array($sanitizer, "selectorValue"), $values) ); // Make the property hold the pages found by the selector $e->return = wire('pages')->find($selector); )); } Then you can do $clientes = wire('pages')->find("template=cliente, cliente_busca=1, include=all"); foreach($clientes as $cliente) { $out.= "..."; foreach($cliente->inmuebles as $inmueble) { $out.= "..."; } } This only makes sense if you always want to fetch the inmuebles in real time. There are other ways to achieve the same results too. Of course if you don't want to create a module, then you could just make a function that returns the selector for the cliente and use that with a find().
-
We have created an LDAP module for PW that supports mapping groups, setting the base dn and storing the e-mail address of the user (for an example). It also has an "Active Directory" -mode. I don't think Marvin's current code works with every AD-instance since it's missing a couple of ldap_set_option() calls that are needed for some. The only reason we haven't released it earlier is that we wouldn't have the time to maintain it. @Marvin: If you want to take a look at the code I can post it on Github and throw you a link. You could always implement all the stuff by yourself as well, I would understand
-
The 403 means there's something wrong with your .htaccess -file or you are trying to access the asset-folder itself (and not an actual file inside there). Could you show us the link and/or code? This shouldn't have anything to do with the 403 you were getting. 128M is perfectly fine for basic web page -stuff. There might be some serious design errors in your code if you are hitting the memory limit, I'm afraid If you could tell us a bit more - paste actual code and so on - we could help more. How large are the catalogs you are uploading?
-
Hey! Sorry for the late response - I've been fairly busy lately. First of all, no, I don't think it's documented anywhere else but here: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/Pagefile.php#L441-L444 The reason for that probably is because it's very rarely needed. I'm glad you worked it out. However I would like to mention that you should rather do // Process the upload only once $filenames = $u->execute(); if(count($filenames)) { // If there's always just one file, no looping needed $pagefile = new Pagefile($p->files, $filenames[0]); $p->files->add($pagefile); $p->save(); echo $pagefile->hash; } You don't need to use the last() -trick - internally ProcessWire is changing the string you are passing to add() to a Pagefile object anyway. Also I assume you haven't enabled zip-file extraction? Because then you should handle all the files returned from the execute() - then you would also have to separate the hashes with something you can parse.
-
Do you mean the field edit view or the page edit view? What theme are you using?
-
Hello, Your question is answered here: http://wiki.processwire.com/index.php/Including_a_page_in_another_page
-
May I ask why aren't you providing the delete-links through the field itself by looping through the items it contains and using the hash of the files to reference them? In other words, why do you need to work with the original filenames? Just to make my point clear // Generate delete-links foreach($myPage->files as $file) { echo "<a href='{$myPage->url}?action=deleteFile&hash={$file->hash}'>".htmlentities($file->name)."</a><br />\n"; } // Then on your controller you can retrieve the file with $file = $myPage->files->get("hash=".$sanitizer->selectorValue($input->get->hash)); $myPage->files->delete($file); $myPage->save(); In the actual implementation you should of course validate the request and also use POST instead of GET, but my point was to just demonstrate the usage of the hash.
-
I don't think the fatal error is related to your Mac installation per se. You are getting the fatal error because $this->page->selected_cases isn't an object. That either means a) $this->page isn't an object or c) $this->page->selected_cases isn't an object. Now, it is hard to debug this for you because you are not telling us the context of your code. Are we inside a template, for an example? What kind of field (i.e. Fieldtype) is "selected_cases"? It would help if you could do echo "Type of selected_cases: ".gettype($this->page->selected_cases)."<br />\n"; echo "Fieldtype of selected_cases: ".strval($this->page->fields->get("selected_cases")->type)."<br />\n"; echo "Page is an object: ".((isset($this->page) and is_object($this->page)) ? "yes":"no")."<br />\n"; ...and then copy/paste us the output. I can say in advance, if selected_cases is NULL, then I'd advise you to check the name of the field. Depending on the field, it could also be it's not holding any items (usually if it's holding multiple items it should then be an empty PageArray, for an example, and then filter() would work). The latter would be easy to fix by checking is_object($this->page->selected_cases). Anyway, if you want proper help, please fill in more details. @horst He posted the errors in the original post
-
Like LostKobrakai said, you want to create a separate module that does the hooking. The key is to make it autoloadable (it usually makes sense to make it singular too). This way the hook will always be active, regardless of where you are. Here's a simple example class MyHookingModule extends WireData implements Module { public static function getModuleInfo() { return Array( 'title' => 'MyHookingModule', 'summary' => 'Just a demo module', 'version' => 1, 'autoload' => true, 'singular' => true, ); } public function init() { $m = $this->modules->get("dataImport"); $this->addHook('LazyCron::everyMinute', $m, 'myFunc'); } } However I would definitely suggest doing it like LostKobrakai suggested. Separate the Process-module from the importing module and with the Process-module, provide only PW admin-related aspects.
-
You shouldn't edit index.php directly. Instead you should create a file called index.config.php and put the following there. <?php if(!defined("PROCESSWIRE")) die(); function ProcessWireHostSiteConfig() { return ["*"=>"myNewSiteLocation"]; } Obviously change the string myNewSiteLocation. Edit: Forgot to mention that if your directory name doesn't start with "site-", you should create your own .htaccess inside your site-directory that protects assets in the same way the main .htaccess does. The main .htaccess protects only the default site folder and folders starting with "site-". You could modify the main .htaccess too, but again you should avoid editing it to make upgrading PW easier.
-
I'm glad I could help! Thank you - excellent points. I'll make these changes and then post the module. Well what can I say, you gave me exactly the little push I needed to go for it
-
Well, this was the reason behind my asking if you were getting errors from the resizing operation. Anyway, I am glad you got it solved
-
I now see your problem, Alexander. Unfortunately that is how Repeater-fields work. I would recommend switching to PageTables, that provide the functionality you need out of the box. PageTable is a feature of 2.5, which will be out any day now. You would define your selector like $selector = "template=chalet, clndr.id=[template=clndr, arrival={$dates}|{$todate}, booked=0]"; PageTables have been available in the dev-branch for quite a while and we are already using them heavily. They are superior to Repeaters in every way. Of course you would have to write a simple script that saves your repeaters to the new PageTable-field - the script would be trivial though and I'd be happy to help with it.
-
Edit: Just to make this clear. Let's say you have the following scenario Chalet ARepeater 1Arrival=2014-09-12 Booked=1 Repeater 2Arrival=2014-09-11 Booked=0 Chalet BRepeater 1Arrival=2014-09-12 Booked=0 Repeater 2Arrival=2014-09-11 Booked=0 When searched with the dates 2014-09-11 and 2014-09-12, do you want the selector to return Chalet A and Chalet B, or Just Chalet B?
-
Right. I know this might sound silly but have you checked the generated HTML for any PHP warnings or notifications? These could happen during the resizing of the image. Also have you checked your browsers console for any JS errors?
-
Thanks Joss. And now just to make sure; on that child template, if you change echo $page->main_image->width(400)->url; to echo $page->main_image->url; ...everything works just fine and dandy, even when rendered through the basic-page template?
-
Please submit the template of the sub-page too