Jump to content

theoretic

Members
  • Posts

    101
  • Joined

  • Last visited

Everything posted by theoretic

  1. Hi there! And, as always, thanks for a perfect product! Would like to discuss an interesting case. Let's suppose we have some images attached to different pages, each image having some extra fields including uid field which is unique. We have to build an api page which should receive requests like /api?uid=efv97yg and it should return some JSON about the image with that uid. Is there any possibility to find an image by its extrafield value (e.g. uid)? Well, i know that we can do something like this: $pages_ = $pages->find('template=page_with_fotos'); foreach($pages_ as $page_) { $images = $page_->images; foreach($images as $image) { if($image->uid !== $uid) continue; $json = json_encode($image); break; } } echo $json; But its not very elegant. And even worse: $sql = "select * from field_foto where uid=$uid"; $query = $database->prepare($sql); $query->execute(); ... What is on my wishlist: //pseudocode, will NOT work for sure! $foto = $field_fotos->get("uid=$uid"); ... Will appreciate any advice. Thanks!
  2. @arjen , grab that! The whole module is not so long, so it's possible to place it right here. @ryan , if You'll have some time, please review my mod. It will take a minute, the mod is really simple. Thanks in advance! ImportPagesCSV.module
  3. Another nice module for PW, thanks @ryan ! Tried to use this module with PW 3.0.55 , no problem, it's compatible. Also did a small mod which enables basic support for FieldtypeMapMarker (lat and lng only). Will share my code if it's interesting for someone.
  4. Hi @LostKobrakai ! Migrations are a great idea. But i had a trouble while trying to use it. My setup: PW 3.0.55 Uikit admin theme Tried to create a test migration and, after defining its type and description, got a PHP error: Error: Call to undefined function wirePopulateStringTags() (line 70 of \site\assets\cache\FileCompiler\site\modules\Migrations\Migrations.module) Need help. Thanks in advance!
  5. Thanks @LostKobrakai and @diogo ! Very reasonable thoughts from you both. Agree that creating a whole new logo could be too radical. But the problem with non-uniqueness still exists. Maybe we need to do some facelifting to the freshest logo included in uikit admin theme. Will think about. @diogo , thanks for the link to the very interesting thread about PW branding, didn't read it before. @LostKobrakai , special thanks for Your opinion about the main PW website. It works like a charm but is a bit outdated from the point of view of visual representation. Can try to draw some sketches on the subject if there will be some interest from the community. Anyway we need to discuss all that because PW is an amazingly powerful and simple tool which truely deserves to be widely known and to have a better brand than now.
  6. Hi all and thanks again for a perfect product! I'm glad to see Processwire growing and becoming a strong, popular product. The new look of admin interface (uikit-based) is nice and minimalistic. Maybe it's the starting point to think about the consistent identity for the whole Processwire project. The only thing which is more or less consistent now is the main Processwire color. Somewhate between red and maroon, I call it "Thai color" because it's very popular in Thailand. You meet this color at almost any page related to Processwire, and it's good because this color is very distinctive. But what's about PW logo? There's no consistency. And, i'm unhappy to reveal it, the PW logo (at least the sign, not the text part) is not absolutely original. There are at least three different Processwire logos: The text part of logo at PW homepage (and pure-textual logo in most admin themes, e.g. Reno). The sign part of logo present at PW homepage. The new logo (only sign, textless) present in the new Uikit admin theme. For sure it's too much. A single, unique, consistent logo could be better. As to the sign -- small b in circle -- just look at Beats Audio logo which is very similar. And even worse: there's a CMS which is very popular in Russia and called Bitrix, and it has a very similar logo. So i would like to propose another vision of PW logo. Unique, original, but being inherited from current PW logos. It's only a first approach, will be glad to polish it in case of positive feedback. And thanks again for a great product!
  7. Thanks a lot Robin S! Will use almost all of Your solutions in process of "progressive development". Step 1: a repeater with all available Offers for any Place, editors are responsible to enter the correct data. Step 2: a hook which restricts Offers after saving the Place. Step 3: Some custom JS.
  8. Hi there! And thanks for Processwire which i really like! Got a specific repeater-related question which i couldn't resolve. Will appreciate any help. Let's imagine we have Places (pages), Offers (pages) and Partners (PW users). Any Place can have many Offers attached to it via a repeater field. Any Partner can have many Places (repeater or a multiple-value field). He can offer some Offers at each Place he is attached to. His Offers for any Place should be selectable only from Offers already attached to this Place. Partner-Places-Offers management should be performed in admin interface via PW input fields. The ideal solution which i imagined could be a "dynamic" partner_place_offers repeater where multiple Offers for a single Place could be selected from dynamically built list dependent on selected Place. But it appears that PW doesn't have such functionality yet. Thanks in advance for giving some idea on the subject!
  9. Hi there and thanks for a perfect product! PW seems to get more and more popularity, and its flexible power begins even to rival the frameworks like Laravel. I really like PW, and that's why i see some ways to make it even better. Frameworks are often installed OUTSIDE the document root. There's a lot of reasons to do so. Some of them: Security. Every piece of code placed inside docroot is a potential security breach. So we are to keep only a minimal amount of code inside docroot. Website engine obfuscation (and more security again). Anyone can check for presence of /site and /wire folders via http -- and if they're here then it's a Processwire inside webroot with almost 100% probability. Possibility to share the same codebase between several websites placed at the same server (it's really cool!). A nice opportunity to create a static site generator (and PW has it all to become such a generator with minimal coding). But, unfortunately, it's not the case for PW right now. PW is currently designed to be placed only inside webroot. And there's no clear way/guideline how to move PW to an arbitrary directory outside webroot. At least i couldn't find any. OK, there will be however some obvious problems while moving PW outside webroot: Many hosters deny ftp/ssh access above webroot. So it will be impossible to upload/download anything inside /site (at least using ftp/ssh clients). There will be some confusion/ambiguity with /site/assets/files . In most cases they should be accessible via http, so they need to be located inside webroot. But, hmmm, what about 'special' files like hi-res images which are to be protected from occasional downloads? Yes we can write some .htacces to protect them -- but placing such files above webroot is a better practice. Tried to 'bruteforce' my idea by moving /site and /wire from fresh PW 3.x installation one level up my webroot and applying some tweaks to /index.php . No success at this time. Had some core-level errors. PW seems to dislike my experiment, core changes are needed. My whishlist? A possibility to define path (absolute or relative to webroot) for /site (except /assets) and /wire during installation and/or after it via config.php file and/or something like $config inside /index.php . A possibility to separate /site/assets into /webroot/something_like_public_assets (this path should be configurable) and /outside_webroot/something_like_private_assets (this path, of course, should be configurable too). A possibility to change/configure paths after installation. Hope this idea is really important for the future of PW. Will be glad to see a deeper discussion here.
  10. adrian, thanks a lot! Got my own solution working, however Your help was very useful.
  11. Thanks adrian! Another great idea from You! It seems You know Your module much better than me, so You'll be faster to add one more action. However i can try to do it in a couple of days.
  12. OK, have some hours spent to resolve the problem. Conclusions: It's possible to clone a repeater item using API,.. ...but it's a delicate procedure which can be performed in the only correct way. Trying to use alternative approaches may even corrupt your database (thanks again to the PW creators for making a very simple and straightforward DB structure which can easily be healed if corrupted!) My way to clone the repeater item from one page to another: //Creating a new page which will hold the repeater clone $newPage= new Page(); $newPage->of(false); $newPage->template = 'my_template_with_repeater_field'; //Setting some more fields skipped ... //Getting the original repeater item $repeaterItem = $pages->get("some_selector=$some_value"); //Saving the page before cloning the repeater -- it's very important! $newPage->save(); //OK let's clone that repeater item now! $repeaterItemClone = $newPage->repeater_field->getNew(); //the repeater clone is already created and saved to the database //Cloning the repeater fields $repeaterItemClone->field1 = $repeaterItem->field1; $repeaterItemClone->field2 = $repeaterItem->field2; //Cloning some more fields skipped ... //Saving the modified clone $repeaterItemClone->save(); Maybe it could be useful to create a PW module for cloning repeater items. Hope this will be useful to someone
  13. Thanks everyone for a perfect product! Got a problem during development of a website which has two different templates sharing the same "suboffers_prices" repeater field: the "offer" template and the "order" template. The idea is to take a single repeater item from offer page and to save it as a repeater item to a newly-created order page. Getting a single repeater is not complicated: $suboffers_prices = $pages->get("uid={$input->post->suboffers_prices_uid}"); But saving that suboffers_prices to a new order page appeas to be not that easy: $newOrder->suboffers_prices = $suboffers_prices; $newOrder->save(); //doesn't save the repeater ...another try... $newOrder->suboffers_prices = $suboffers_prices; $newOrder->suboffers_prices->save(); //in fact saves nothing ... $newOrder->save(); //doesn't save the repeater ...and another... $newOrder->suboffers_prices->getNew(); //$newOrder->suboffers_prices->of(false); //not callable in this context, PW crashes with error $newOrder->suboffers_prices = $suboffers_prices; $newOrder->suboffers_prices->save(); //again saves nothing ... $newOrder->save(); //again no repeater saved Tried some other approaches, still no result. Would like to get any advice on the best practice for saving a single repeater item to another page. Thanks in advance!
  14. Thanks again justb3a! You're the best
  15. 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!
  16. 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!
  17. 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.
  18. @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.
  19. 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
  20. 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.
  21. 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?
  22. @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.
  23. 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
×
×
  • Create New...