Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/04/2019 in all areas

  1. Hi @sambadave, if the available solutions do not fit, you can modify the markup of any field as you want quite easily. One option is the Inputfield::render hook. First, start with a general hook to check if everything works: // /site/ready.php $wire->addHookAfter("Inputfield::render", function(HookEvent $event) { bd('fired'); }); You should get lots of dumps when opening your page (using TracyDebugger of course): Make it conditional to only fire for your field and change the class to InputfieldSelect to be more specific: $wire->addHookAfter("InputfieldSelect(name=availability)::render", function(HookEvent $event) { bd('fired'); }); It will fire only once: The HTML is in the "return" property of the $event: $wire->addHookAfter("InputfieldSelect(name=availability)::render", function(HookEvent $event) { bdb($event->return); }); You can then modify this html like this: $wire->addHookAfter("InputfieldSelect(name=availability)::render", function(HookEvent $event) { $html = $event->return; $html = str_replace("value='1'", "value='1' style='background: red; color: white;'", $html); $html = str_replace("value='2'", "value='2' style='background: blue; color: white;'", $html); $html = str_replace("value='3'", "value='3' style='background: green; color: white;'", $html); $event->return = $html; }); For more complex modifications it's better to hook the field before it get's rendered (search the forum via google for ProcessPageEdit::buildForm). You can also see https://github.com/BernhardBaumrock/TemplatePreviewImages for a simple example of modifying inputfields and applying an additional library.
    7 points
  2. Thanks to bernhard and Autofahrn i have come up with this example code and run it in TracyDebugger on a test page with a image field and it works beautifully. <?PHP /* get and save a new image to image field Pageimages array */ $page->of(false); $pageImages = $page->images->add('https://www.somesite.com/image_of_tree.jpg'); /* save the page (perhaps not needed but there for comfort.) */ $page->save(); /* get the last added image */ $lastImage = $page->images->last(); /* debug before changes */ d($lastImage, '$lastImage before changes'); /* add tags to the image and description */ $lastImage->addTag('test'); $lastImage->addTag('Tree'); $lastImage->addTag('Syren'); $lastImage->addTag('Sun'); $lastImage->addTag('Sunny'); $lastImage->description = 'This is a beautiful tree.'; /* debug info */ d($page->images, '$page->images'); d($lastImage, '$lastImage'); /* save the page */ $page->save(); ?> I used the following API docs and mentioned forums users help to accomplish this: https://processwire.com/api/ref/pageimage/ https://processwire.com/api/ref/pageimages/ https://processwire.com/api/ref/pagefile/ https://processwire.com/api/ref/pagefiles/ Just wanted to post this at the end so others who wonder about this could get a starting point.
    4 points
  3. I'm not sure, but maybe you could look at https://github.com/processwire/processwire/blob/master/wire/modules/Inputfield/InputfieldIcon/InputfieldIcon.module which is used in template settings under tab "advanced" and create something similar?
    2 points
  4. Negative, wasn't I, perhaps some other organized fellow? lol I always skipped that part of the set-up, as well as anything related to version control. I prefer to have full control of what I install. And I also have VirtualHosts set up and working fully. If you should need help with that, let me know. I'll share the code/commands here ?
    2 points
  5. In recent posts, Kongondo has mentioned quite a bit about his use of Linux. I am certain there are other users of Linux here in the community forums of ProcessWire ??? I have been a loyal user of FOSS and GNU Linux for as long as I can remember. Every single Android device I have owned has been rooted. My Linksys router runs DD-WRT. Every computer I have had has had some distribution of Linux at one time or another. Back in the late 90's my ex-girlfriend gave me a big box set of Suse and another of RedHat. I have since then distro-hopped from those to Arch, Mandrake, Suse, everything *buntu and I settled on Crunchbang++ for a few years. I have yet to play with CentOS or Linux From Scratch (LFS) but that is on the horizon ? I have always preferred Debian and everything in its family tree, including Sparky. I just don't like XFCE nor LXDE. Openbox has always appealed to me, as well as i3wm. I finally got around, by special request by Kongondo, to share my LAMP set up. It's a file I have modded over the years but it remains pretty simple. I formatted it to MarkDown and threw it up on github for your viewing. I hope to help our growing community in something I kinda sorta know a bit about ? https://github.com/OrganizedFellow/LAMP
    1 point
  6. 1 point
  7. You will find a page's basename in the "name" column of the "pages" table.
    1 point
  8. https://www.npmjs.com/package/benny-hill !!! ??
    1 point
  9. I have the same need and I was planning to use RunTimeMarkup module in some way to accomplish this. The difference is that I have these settings on my ProFieldMatrix content blocks instead. Didn't do it yet though, as I have to finish other things first on the project. But If you give it a try, let me know how was it.
    1 point
  10. Nice module! Thanks for sharing.
    1 point
  11. I was reading a bit about Cloud9 yesterday, which is now an AWS service. Could this (cloud in-browser IDE and everything running on a remote server) be an ideal solution for developing on a low-end machine? There is also a github-trending code-server which offers vs code in the browser. But it probably will need much more effort to set up. Just for an alternative
    1 point
  12. 1 point
  13. v0.1.2 released - this update allows the 404 page markup to be replaced.
    1 point
  14. So I tried Midori and it rendered ProcessWire website all funny. The Firefox that shipped with BunsenLabs (BL) seemed to be fast enough so I thought, what the heck, maybe Chrome will run just fine as well? We'll, what do you know! Of course it's eating up RAM like it's Google's Birthday but I reckon @OrganizedFellow was right about Solus being 'slow' on my machine due to the visuals. Since BunsenLab has a very light footprint, Chrome still has enough to chew on. I then tried Sublime Text. I've always loved Sublime but after using VSC, going back was difficult. I decided to install VSC to see if it would run OK in BL. Surprise! So far, it seems to run just fine. I haven't opened multiple files (and I don't need to in this machine). I'm just happy I am able to use the tools I am used to without hiccups. One other thing I liked about BL (yes, we are on first names now ;-)) is that it has a post-install script that runs and asks you if you want to install useful tools like a LAMP stack, etc. I let it install the LAMP stack and here I am, up and running. Apache2, PHP 7 with many useful extensions, phpMyAdmin, etc. ps: @OrganizedFellow, was that you who made the request to BL to port the CB welcome script to BL? :-). If it was, thanks!
    1 point
  15. @Pete, @Erik, seems to work with a tiny modification in the foreach loop (loading an intermediate variable with $fM['type']): // Now use $data and $fieldsModel loop to create all checkboxes foreach ($fieldsModel as $f=>$fM){ $fmType = $fM['type']; $fields->add( self::$fmType($f, $fM['label'], $data[$f], $fM['desc']) ); }
    1 point
  16. Out of curiosity, can you dump the data being sent out and validate it's the proper data you intend to send also this stackoverflow also details a way of making PATCH curl calls. https://stackoverflow.com/questions/14451401/how-do-i-make-a-patch-request-in-php-using-curl
    1 point
  17. I have written tutorials here and various tutorials before, it's fun for me however I think starting small is a good idea. I will create a thread for this today or tomorrow where we can deliberate on table of contents and all.
    1 point
  18. If you create variations from an existing PageImage, they exist as files only, there is no need to save the page afterwards. For that reason you may create variations on the fly during output (i.e. thumbnail with reduced size).
    1 point
  19. v0.0.9 adds support for dynamic rowHeaders. Previously they had to be manually defined via JavaScript. Now they can be defined by user input:
    1 point
  20. As @bernhard said, the add returns the whole PageImages array including the new, unaltered image file. You may create variations afterwards but if you need to do some "editing" before, you'll probably have to go through PHP, download the file into a temporary folder, perform any kind of manipulation and then add the local file to the PageImages array.
    1 point
  21. You could use something like this: $refs = $pages->find("template=project, title%=Zürich, include=all, limit=3"); // limit here just for testing small result-sets $count = count($refs); $last = $count-1; $c = 0; echo "<p>$count</p>"; foreach($refs as $r) { switch (true) { case ($c === 0): echo "<hr><strong>FIRST: {$r->title}</strong><br>{$r->project_desc_short}"; break; case ($c === 1): echo "<hr><strong>SECOND: {$r->title}</strong><br>{$r->project_desc_short}"; break; case ($c === 2 && $c === $last): echo "<hr><strong>LAST: {$r->title}</strong><br>{$r->project_desc_short}"; break; case ($c === 2 && $c != $last): echo "<hr><strong>THIRD: {$r->title}</strong><br>{$r->project_desc_short}"; break; default: echo "<hr><strong>DEFAULT: {$r->title}</strong><br>{$r->project_desc_short}"; break; } $c++; } echo "<hr><br>" . $refs->count . " Referenzen gefunden"; see also https://www.phpknowhow.com/basics/if-else-and-switch-case/#highlighter_461554 Perhaps you could use this technique (PHP 7.2+), with goto: https://derickrethans.nl/php7.2-switch.html
    1 point
  22. Although I don't know what your reasons for using var_dump(), I really recommend that you use the module TracyDebugger instead. It will give you better and cleaner information regarding any ProcessWire objects and their properties.
    1 point
  23. And if it's mainly within CKEditor fields that you want to reuse images from a central media library then there is this module from @BitPoet: Media Library
    1 point
  24. Hi @MarcoPLY, welcome to the forums. Imagefields are tied to a page, therefor the images you upload through this page are stored under /site/assets/files/<ID-OF-THE-PAGE>/. You are using repeaters, maybe as one of multiple options to reuse fields on a single page. Repeaters are also pages (behind the scene), therefor the images you upload to a repeater item are stored under /site/assets/files/<ID-OF-THE-REPEATER-PAGE>/. For all images you want to use in multiple places, one recommended way is to create a hidden page with an imagefield. Some people don't create an extra page but uses their homepage for that. Both do store all the stuff that is needed on multiple places, also text like contact data, files and not only images. But let us focus on the images now: If you need them into different pages with ckeditor fields, you need to click on the images button. In the opened dialog you can read " If you would like to select images from another page, select the page below.". Below is the name of the current page and a button or link called "change". Clicking on it opens a page tree to let you choose another page. (The homepage is the first one, what may be the reason some people store their reusable stuff there). With clicking on the pagenames you can traverse through the tree to every single page that exists in your system. Clicking "select" on the page of your desire displays all its images as thumbnails.
    1 point
×
×
  • Create New...