-
Posts
4,077 -
Joined
-
Last visited
-
Days Won
87
Everything posted by horst
-
- 16 replies
-
- 1
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
Create Page from OpenImmo XML Files (Images)
horst replied to hellerdruck's topic in API & Templates
Oh sorry, I haven't read thoroughly. Please do a var_dump check what the "$xml->anbieter->immobilie->anhaenge->anhang->daten->pfad" contains. It looks a bit suspicious, as it is the same in all image cases. There seems to be a missing differenciation in the node "anhang". Maybe you have to loop over the anhaenge as anhang? foreach ($xml->anbieter->immobilie->anhaenge as $anhang) { // check conditions ... (attributes of $anhang) ... // when found the header image url: $object->object_header_img->add($anhang->daten->pfad); } -
Create Page from OpenImmo XML Files (Images)
horst replied to hellerdruck's topic in API & Templates
I think you simply can use one code line to add a file to a pagefile(s) or pageimage(s) field. When output formatting is off, what it must be when modifying a page via API, there is no difference between singular and multiple file fields. They are always multiple. The difference for a singular field only exists for output! So following your simplified code should work. Can you test this please and report back? foreach ($xml->anbieter->immobilie->anhaenge->anhang->attributes() as $attribute) { $object->object_images->add($xml->anbieter->immobilie->anhaenge->anhang->daten->pfad); } $object->save(); -
Another thing, on PW site, would be to allow upload of zip(ed) files to pagefile pageimage fields. As a workaround.
-
RockIframe - Splitscreen preview for PW backend
horst replied to bernhard's topic in Modules/Plugins
Hey @bernhard seems to be a very good timing to me, this release! ? One question: how would I tell the Iframe to load a page with urlsegments? I don't need to render a file- or imagefield but a sort of external or sibling page that need to be called with an id of the current edited page. Is this possible? -
Hi @titanium, I don't have had time to install PHP 8 and test out all my sites and modules under it. I will do so with priority for WireMailSmtp. But it may take 1 or 2 weeks, sorry.
-
The only thing what I remember is a login throttle module. Maybe you can copy this and adapt it for your use case, or borough some pieces of code from there?
-
Looks fine to me ? Hi @wwwouter, welcome to the forums. To your question about generating a dynamic CSS file via PHP, I would do it like this: 1) create a php file for example called "dyncss.php" and copy it under site/templates/ (look that it starts with a namespace signature "<?php namespace ProcessWire;" 2) in pw admin under setup > templates > addNew create a new template and select dyncss as its template file 3) in your site/config.php create a appropriate content header for css files, according to the advice "To add more content types see contentTypes in /wire/config.php (and add them in /site/config.php)." // in site/config.php merge our custom types into the existing core ones $config->contentTypes = array_merge($config->contentTypes, array( 'css' => 'text/css' ) ); 4) now open the template in backend under setup > templates > dyncss and adjust some settings: a) under family tab set "no, may not have children" and for example "can be used for new pages = one", if you only want to have one unique page of this type b) under the files tab disable the compiler, under content type select css, and if you use delayed output with prepend and append files you have to disable this here for this content type c) adjust others as you may like or need and save and close the template 5) create a page in your page tree that has this template, give the page a page name that you want to call as url for your dynamic css file for example "mycss" 6) put all your php/css magic into the php file under site/templates and add the URL of your generated page where ever you need it in your generated html If you later on want to use more than one dynamic css file, you can decide to allow more than one page with that template, or go the root with url-segments and a single page what I would prefer. But first I hope this can be a good starting point to get you going. If questions arise, come back here into this thread again and ask. ? Happy exploring and coding.
-
Hi, I use a saveReady Hook and want to set values of the name field according to values from other fields. But only the name field of the default language is updated, regardless of the language the user is in. When saving via API scripts, the result is the same as when saving interactive via page editor. My code is as follows: $this->pages->addHookAfter('saveReady', function($event) { $p = $event->arguments[0]; $lang_DE = $event->wire->languages->get(1016); $lang_EN = $event->wire->languages->get(1018); $newName_DE = 'ein-generischer-neuer-name'; $newName_EN = 'a-genric-new-name'; $p->setLanguageValue($lang_DE, 'name', $newName_DE); $p->setLanguageValue($lang_EN, 'name', $newName_EN); } How can I set (andSave) the other language name too in a saveReady Hook? Or do I need to use another hook for that? EDIT: The above code works as expected. It was interfering with special scripts / hooks on my development site. ?
-
Get rendered output of page programatically - useMarkupRegions
horst replied to baronmunchowsen's topic in General Support
This exception says that it has found something that was expected to be a object of type pageimage but maybe it is not what can be the case if there is a empty pageimage field in your template and you have not a check for that in your template file, so simply calling pageimage::srcset on an empty object (null). First you should inspect your involved page and template about this. If you find that there is a valid pageimage object (with available image object) that triggers this exception, you must find out why the srcset method isn't known at this state. But I would go first step first. Mostly there is no second step needed after it. ? -
how to deal with upper/lowercase in repeater field ->sort()
horst replied to cabrooney's topic in General Support
maybe this can help you out: https://processwire.com/api/ref/wire-array/sort-flags/ (but haven't tested anything myself) -
here is one from ryan: here is another (that I don't know) and more can be find using the g**gle site search.
-
I don't get what you are looking for, if you need no registration in the front. Do you need a Login form in the front? It must have at least a username and a password field, Additionally some security protection like $session->CSRF would be good, for example. There are examples here in the forums for those simple steps. Maybe I will find one. wait, ...
-
Hey, I know I used it already somewhere but can not remember / find it now. ? Within an Inputfield in a PageEditor, it can be important to detect if the inputfield is on the base page or on a repeater item. Exactly I need to get the precise name of the field. For example if a user named his field foo, I can get the name by calling $this->hasField->name from within my inputfield module. When the field is on a repeater, its final name is not foo but foo_repeater1234. That's what I'm after. What method(s) can help me to get this from within the inpufield module?
-
Hi @bernhard, thats a nice and short one! ?
- 1 reply
-
- 1
-
Sorry I'm short in time ATM, but I think in general this is handled by PHP https://www.php.net/manual/en/function.set-error-handler.php You will find such function calls in pws wire directories, for example in WireHttp.php and other files. As far as I remember right, it is possible to define multiple handlers in PHP that you can use by "bubbling" (or cascading) and maybe conditionally exit that at any point. You definetly dont't need to hack the core. Maybe the PHP manual is a good starting point. Next would be to find where PW handles it and how to set you above this, do your logging and after that pass the event through to PWs handler where needed.
-
Hi, the use case is that I have a Profields Textareas inputfield with 3 subfields that I call A, B, C in the example. The user should have to fill in A & B, but not C. C is optional and only used in under 10% of all entries. Is it possible to define a requirement for selected subfields of inputfields without a hook? Or need I to use a hook for that? If yes, is there one other or better then Page::SaveReady? Any hint is appreciated. ?
-
So definitely it cannot be available in $config, because $"config is parsed before the engine gets started". Way before init is running and much way before ready! And most of the functionality only is available after (the engine is) ready! ?
-
Now it does. ? Here you go: https://github.com/horst-n/PageImageManipulator
-
Another candidate can be https://feathericons.com/ But when inspecting the svg code of the arrow-up in a circle from all three icon sets it comes out that they use very different number of chars: // Heroicons: 239 chars <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 11l3-3m0 0l3 3m-3-3v8m0-13a9 9 0 110 18 9 9 0 010-18z" /> </svg> // Feather icons: 365 chars <svg xmlns="http://www.w3.org/2000/svg" class="feather feather-arrow-up-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="10"></circle> <polyline points="16 12 12 8 8 12"></polyline> <line x1="12" y1="16" x2="12" y2="8"></line> </svg> // Tabler icons: 453 chars <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-up-circle" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"/> <circle cx="12" cy="12" r="9" /> <line x1="12" y1="8" x2="8" y2="12" /> <line x1="12" y1="8" x2="12" y2="16" /> <line x1="16" y1="12" x2="12" y2="8" /> </svg> So in regard of file size and data compression the winner is Heroicons. The number of icons in Tabler is nearly 1000, Feather has 280 and Heroicons 220. And when it comes to design, ... well, thats purely personal opinion. ?
-
module PrivacyWire - Cookie Management & async external asset loading
horst replied to joshua's topic in Modules/Plugins
EDIT: found the problem! | orig. post -------------------------------------------------------------> I have a need to manually use the textformatters of VideoEmbed and PrivacyWire. As far as I understand it, it should be possible to do it with VieoEmbed first and PrivacyWire second. But it seems not to match with the video I tried. My code is: // A) $videoMarkup = "<p>{$blogitem->blog_video_url}</p>"; // B) $mod = wire('modules')->get('TextformatterVideoEmbed'); $mod->format($videoMarkup); // C) $mod = wire('modules')->get('TextformatterPrivacyWire'); $mod->format($videoMarkup); Debug outputs are: // A) array(1) { ["$videoMarkup"] string(49) " <p>https://youtu.be/XXXXXXXXXX</p> " } // B) array(2) { ["Textormatter"] object(ProcessWire\TextformatterVideoEmbed)#458 (1) { ["data"] array(7) { ["maxWidth"] int(640) ["maxHeight"] int(480) ["responsive"] int(1) ["rewind2start"] int(1) ["clearCache"] string(0) "" ["uninstall"] string(0) "" ["submit_save_module"] string(8) "Absenden" } } ["$videoMarkup"] string(492) " <div class='TextformatterVideoEmbed' style='position:relative;padding:30px 0 56.25% 0;height:0;overflow:hidden;'><iframe style='position:absolute;top:0;left:0;width:100%;height:100%;' width="640" height="360" src="https://www.youtube.com/embed/XXXXXXXXXX?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> " } // C) array(2) { ["Textormatter"] object(ProcessWire\TextformatterPrivacyWire)#491 (1) { ["data"] array(5) { ["open_tag"] string(2) "[[" ["close_tag"] string(2) "]]" ["video_category"] string(14) "external_media" ["uninstall"] string(0) "" ["submit_save_module"] string(8) "Absenden" } } ["$videoMarkup"] string(492) " <div class='TextformatterVideoEmbed' style='position:relative;padding:30px 0 56.25% 0;height:0;overflow:hidden;'><iframe style='position:absolute;top:0;left:0;width:100%;height:100%;' width="640" height="360" src="https://www.youtube.com/embed/XXXXXXXXXX?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div> " } Is it wrong how I used it, or why isn't it working as expected, or where can I look into to find the reason? <------------------------------------------------------------ orig. post | EDIT: To answer my own question: "Yes I used it wrong!" ? // C) $mod = wire('modules')->get('TextformatterPrivacyWire'); $mod->format($videoMarkup); This was wrong. The TextformatterPrivacyWire module only supports the method ->formatValue(), not ->format(). The following line works and now the result is as expected: $mod->formatValue(new Page(), new Field(), $videoMarkup); So, just wondering why it not uses the format() method, because there seems no need for a page and a field? -
In the parent page you have to set the sorting to manually drag. DO NOT set any hard sort order there. Then you can use the add new childs first method from AOS. This results into the following behave: Everytime you add a new child to that parent page, it is added on top of the list, as first child under the parent. From there on, you can drag and sort this and all other pages manually as you like.
-
This is not a direct answer on the current problem, but shows a different method for using a custom var in different scopes: Instead of using a superglobal var it may also be possible to use ProcessWires Functions API with a custom var name. // initialize a custom var, maybe in your site/_init.php region('hannaCounter', 0); // later in your templates or modules or where ever, count up the counter region('hannaCounter', region('hannaCounter') + 1); // and where ever you need it, get the current (or final) counter value echo region('hannaCounter');
-
Are you using AOS? (AdminOnSteroids module) It enables to configure a lot in regard of CKE.