theoretic
Members-
Posts
111 -
Joined
-
Last visited
Everything posted by theoretic
-
Thanks justb3a! Works like a charm. Another tricky question. Let's suppose that i decided to fetch some images with language fields via Ajax request. The endpoint which receives that request is a Processwire page so all Processwire API functions are available. The data structure for each image is like this: {"name":"dscXXXX.jpg","title":"A multi-language title","uid":"2aa1"} The endpoint call may include something like ?uid=XXXX&lang=en , so the endpoint is language-aware and should return the title in the desired language. Fetching image by uid is not a problem, but how to force our endpoint to fetch the multi-lang title for the desired language? At the moment i found the only solution which is quite hacky. Let's suppose we have the "english" lang page id = 1000. So the data structure for the $image object will be like this: ... title->'The title in default language', title1000->'The title in english' ... So i can get English title like this: $title_en = $image->title1000; Could You give me any advice how to fetch the multi-lang image field value for desired language in a less hacky way? Thanks in advance!
-
Hello there! And thanks for a perfect module. I have an interesting question. How can i programmatically set the values for multilanguage custom image fields? Tried several approaches, everything fails. Will appreciate any help. Thanks in advance! Approach 1. Trying to switch current lang: //...somethere inside a module... $this->page->of(false); $languageCurr = $this->user->language; //russian $this->user->language = $this->languages->get("en"); //image retrievinig skipped $image->title = 'an english title'; $image->save(); $this->user->language = $languageCurr; $this->page->of(true); Approach 2. Trying to use setLanguageValue(): $en = $this->languages->get("en"); $image->title->setLanguageValue($en,''an english title'') ; //gives error Approach 3. Trying to use special names for needed field: $this->page->of(false); $image->title_en = 'an english title'; //not stored at fact $this->page->of(true); Thanks in advance!
-
Snippets / chunks / blocks / template inside templates
theoretic replied to piranha's topic in Wishlist & Roadmap
Think this (truly interesting) subject needs some clarification. "Chunk" is a term from ModX CMS word. In ModX "chunk" means a piece of HTML markup which can be reused on different pages via inclusion into templates and/or via placing a reference to it into page fields. OK, Processwire appears to have a dead-simple solution: we can just "include ./path/to/chunk.php" anywhere in the template files. Great for developpers, bad for content editors. They cannot edit chunks from inside backend. In fact, content editors have no need to use "templates inside templates" and other stuff concerning development, not content editing. They just need a possibility to edit some pieces of HTML code via backend. The typical example is the contact info in footer area. Phones and emails can change, and it's obviously a content editing task to change them, not a development tack. And, yes, Marco's module doesn't resolve the problem, it just helps to separate logic and presentation. Personally i think that the absence of "chunks" editable from backend is a rare point where Processwire is some steps behind ModX. -
@teppo, thanks for a nice feedback! Adding my idea to Github issues could be great. Would also add another suggestion. The "Keep uploaded archives after unzip" option could be context-dependent. E.g. it will be great to have possibility of setting it globally but to override this behaviour for certain templates.
-
Hi everybody and thanks again for a great product! It happened to me to develop a website with pages containig a FieldtypeFile input. Backend users can upload zip archives there, and that archives are auto-extracted immediately after upload (of course I checked the 'unpack zip files' in Input section of my FieldtypeFile input). But the original zip archive is auto-deleted after that, and it is not present in both backend and $page->files array. However I would prefer to keep both the original zip file and all files extracted from it. This may be very useful if we want to give users the possibility to download all files associated with a certian page as a single zip archive. The quick analysis led me to /wire/core/WireUpload.php:saveUploadZip($zipFile). This function deals with uploaded zip archives. I modified it, and now all my zip uploads are not deleted after zip auto-extraction. I did it in a quick and dirty way but it could be done much better. E.g. a special config option "Keep uploaded archives after unzip" could be introduced. Can do it if the community will have some interest. My WireUpload file is attached below. WireUpload.php
-
Hi guys! And thanks for a perfect module. I would like to propose a small tweak. Function render() generates some HTML and Javascript. The problem is that the Javascript code implicitly requires JQuery. Here's an example: this.hoverBox = $(markup); If JQuery is not loaded before, this javascript code will generate an error. I propose to wrap the map-generating Javascript into function which executes after the whole document (including the JQuery call) is loaded. Example: window.onload = function(){ /* original MarkupGoogleMap javascript code goes here */ } This tweak should be inserted into original MarkupGoogleMap.module file. Real code example: $out .= "<script type='text/javascript'>" . " window.onload = function(){". "if(typeof google === 'undefined' || typeof google.maps === 'undefined') { " . "alert('MarkupGoogleMap Error: Please add the maps.googleapis.com script in your document head.'); " . "} else { " . "var $id = new MarkupGoogleMap(); " . "$id.setOption('zoom', $zoom); " . "$id.setOption('mapTypeId', google.maps.MapTypeId.$type); " . ($options['icon'] ? "$id.setIcon('$options[icon]'); " : "") . ($options['iconHover'] ? "$id.setIconHover('$options[iconHover]'); " : "") . ($options['shadow'] ? "$id.setShadow('$options[shadow]'); " : "") . ($options['useHoverBox'] ? "$id.setHoverBox('" . str_replace("'", '"', $options['hoverBoxMarkup']) . "');" : "") . $options['init'] . "$id.init('$id', $lat, $lng); "; foreach($pageArray as $page) { $marker = $page->get($fieldName); if(!$marker instanceof MapMarker) continue; if(!$marker->lat) continue; $url = $options['markerLinkField'] ? $page->get($options['markerLinkField']) : ''; $title = $options['markerTitleField'] ? $page->get($options['markerTitleField']) : ''; $out .= "$id.addMarker($marker->lat, $marker->lng, '$url', '$title', ''); "; } if(count($pageArray) > 1 && $options['fitToMarkers']) $out .= "$id.fitToMarkers(); "; $out .= "} } </script>"; Tried this tweak in one of my projects, works like a charm.
-
Reading docs may really help sometimes... Quote from the @hellomoto's code: elseif($field->type instanceof FieldtypeMapMarker) { $value = trim($value); $page->set($name->address, $value); } And now some code from Map Marker docs ( https://processwire.com/talk/topic/9711-map-marker-map/ ): $page->marker->address = 'Disney Land'; Now it's obvious that Hellomoto's code should be like this: elseif($field->type instanceof FieldtypeMapMarker) { $value = trim($value); $page->$name->address = $value; } Tried this, works like a charm. Lat and Lng subfields are generated automagically if the address is more or less correct. Thanks @Hellomoto for a great mod! @Ryan, maybe it's time to add this to Your original module?
-
@adrian, thank You for help! Tried to use Your module. Compared to ImportPagesCSV it's almost rocket science but after a couple of unsuccessful attempts i managed to get the things done. Mmm, almost done. Some of the settings i tried to use: Mode: Update Field separator: tab Field enclosure: " Ignore the first row: yes Field pairings: 1:title 2:location.address Test CSV string structure: test2 "SomeStreet, 2, building 4, City, Country, 111111" (white space after test2 is a tab symbol) And, after importing that string, bingo! I got the page called test2 "SomeStreet with address 2 and geolocation gone totally wrong. Obviously it's a bug with field separator. Your module always uses comma as field separator and ignores the user-entered separator and enclosure settings. Tried also to use semicolon as separator: the issue persists. OK, i could potentially give up and use commas... but it's no way since addresses always have commas. Will be very glad to get some in-depth explanations about how to get this work.
-
Great mod. But importing Map Marker didn't work for me. Could anyone help please? Also posted this here: https://processwire.com/talk/topic/383-module-import-pages-from-csv-file/page-9
-
Hi guys, and thank Ryan for the great job! I would like to give more attention to this mod: https://processwire.com/talk/topic/8788-trying-to-add-addl-fieldtype-support-to-importpagescsv-mapmarker-repeater-page-%E2%9C%93/ Currently i'm trying to import a list of pages with Map Marker field. Tried the mod, it doesn't work for me. The rest of fields are importing as expected. Noticed that the MySQL table storing my Map Marker field values stores address in the field named 'data'. Tried this in importPageValue(): $page->set($name->address, $value);//doesn't work! $page->set($name->data, $value);//doesn't work! $page->set($name->lat, $value);//doesn't work! Hope someone may help. Thanks in advance!