Leaderboard
Popular Content
Showing content with the highest reputation on 07/27/2022 in all areas
-
Old question but I have just had to do the same so for those looking for this answer in the future, you might want to do something like this: https://stackoverflow.com/questions/16251625/how-to-create-and-download-a-csv-file-from-php-script#answer-54433375 The key parts to implement are: the headers, handling the output buffer, fopen( 'php://output', 'w' ), and exiting at the end. The rest must be implemented as you see fit. EDIT: it might be better to export data into an excel file, for example when non-ASCII characters are in the text data. I found this package to export to excel with only two lines of code: https://github.com/shuchkin/simplexlsxgen (for CSV see its sister project https://github.com/shuchkin/simplecsv) $xlsx = SimpleXLSXGen::fromArray($array2D); //the array to be expored is prepared in advance $xlsx->downloadAs($filename); //initiates the download3 points
-
Hello @Liam88, you probably see these errors now, because you have enabled the debug mode of ProcessWire on your local copy or XAMPP has display PHP errors enabled. I think on your live server display PHP errors is disabled and you should have not enabled the debug mode of ProcessWire. The error you get now is, when you try to output a property of something that is not set. You should first check if something exists, before you try to access the properties: <?php if ($page->header_image) { // Do something } If there is no image, then you cannot access the properties "url" or "description" and get the errors. Regards, Andreas3 points
-
3 points
-
Now I feel like I am just hijacking this thread, but another big shout-out, this time to @elabx3 points
-
https://methodsanalytics.co.uk/ What makes this project cool: We integrated an impossible geometry concept using 3D, Three.JS - Shown in main concept and used for Error 404 concept. We allow the client to create impossible geomerty in the ProcessWire CMS. We created the 3D editor which loads in with a process module. Custom front-end design and UI and full content management across evey aspect of the site. Modular system for page content providing maximum flexibility on page construction. Health check feature looking for broken links and lorem ipsum, page scanning tool. SEO module with global editing section across all pages. Global shared content modules. Methods-Analytics.mp42 points
-
Next up is @Jonathan Lahijani !! Really appreciate the support everyone.2 points
-
@bernhard This is going to be so powerful. I've done a few videos (not for dev) over the years, it sure takes a lot more time than people think it does. Good luck with that! Really looking to RockFrontend! Thank you for your work.2 points
-
@DaveP Thanks for spotting that broken link - fixed now (Its a hard coded link in the template so the weirdness was due entirely to my fat fingered typing). It is possible to get decent scores in WordPress but it's just so much more effort than it is with PW. and @bernhard - good spot on that layout issue. It was a long URL that was pushing a div out wider than it should have been. Interestingly it was fine in Firefox, which is what I use for development, and only breaking in Chrome / Webkit browsers. I guess this means I really ought to use Chrome for development more to catch this kind of bug which is going to affect more users. Shame because I feel we ought to support FF as much as possible.2 points
-
2 points
-
Just wanted to send a big thanks @flydev ?? for being my first Github sponsor!2 points
-
May I ask you why are you trying to resize svg? Svg are scalable by nature, so my personal approach you be to size them via css or html attributes on the svg tag itself.2 points
-
Many members of the community create modules that are very helpful for me and others and offer great support for these modules. We can offer our appreciation with a thanks in a forum post etc.. which is great and gives a feel good factor.. but to create and support modules can take a great deal of time and energy and with this in mind I was thinking how it would be nice if we could show our appreciation by having the opportunity donate beer money to authors of modules that we use. How about if a donate button is displayed on each module page so that donations could be made to the author of the module?1 point
-
Migzen.net is a site we designed and built for Lancaster and Birmingham Universities that gathers academic research into the effect Brexit is having on migration. Obviously we'd best not get into the whole Brexit debate here, so just let me apologise profoundly on behalf of my country and move on to the site... It was a new project, so we were able to create the brand and design from scratch which is always nice. It also gives us the opportunity to make sure colours are accessible for use on the website. As well as the usual blog posts and pages, there's a couple of slightly fancy things we did for them; one of which was to automatically import pages and media whenever they add a new episode to their podcast feeds. We do this using a cron job which loads the MarkupLoadRSS module and parses their XML podcast feeds. If we find any new episodes then we create pages for them with the episode summary from the XML and a nicely styled embedded media player to listen to the audio. We also built them a searchable database of academic resources. That was fairly straighforward, but we do make use of WireCache to build the tag cloud when a page is saved - we use $page->references to work out an article count for each tag which would be expensive to do each page load. There's also a neat looking Timeline which is just built using a repeater field. Honestly PW is ideal for this kind of thing. The site gets good scores in Observatory and Lighthouse (thanks ProCache), and most importantly the client is very happy using PW to keep the site up to date.1 point
-
I'm not sure if that is possible with a selector, but a workaround would be to add a second hidden field to your template and create a hook that populates that field on save or saveReady. Then you can simple use a selector like this: $pages->find("template=yourtemplate, your_hidden_reference_field=$yourpage");1 point
-
What about: $pages->findOne('page_reference=value') Not tested but findOne method should return just the first occurence of the page array.1 point
-
https://processwire.com/api/ref/wire-array/first/1 point
-
Hey @Greg Lumley I wanted to finish my video about RockFrontend last week or weekend, but it turned out to be a lot more time consuming that I thought ? Yesterday I even realised that some parts of RockFrontend could be improved even more, so I decided to do some important updates before finalising the video. I love those new additions ? To get live reloading for example is now really just installing the module and adding "$config->livereload = 1" to your PW site ? No injecting of scripts whatsoever... Back to topic: Today I had to build an accordion content-element: <ul> <li n:foreach="$block->items() as $item"> <a href="#">{$item->title}</a> <div>{$item->content()|noescape}</div> </li> </ul> IMHO it can't get any cleaner ?1 point
-
Quick heads-up: As of version 0.35.0 SearchEngine supports indexing file/image custom fields. In order to avoid surprises, I ended up adding these as separately selectable indexed fields. For an example: in order to have custom field "author_email" for image field "photo" indexed, you'll have to select "photo.author_email" from the "indexed fields" list in module config. There's a "file_field.*" setting available as well, in case you want to index all existing custom fields for a specific file field. Note that description and tags also need to be specifically selected. In earlier versions description text was always indexed, but now if you select the file field name and nothing more, only file name(s) (and content, if you have a suitable file indexing module installed and enabled) are indexed. -- In order to index file/image custom fields I had to refactor parts of the Indexer class. I hope I didn't break too many hooks, but there's a possibility that something goes wrong. Please test carefully, and let me know if you run into any issues!1 point
-
I'm in need of using this condition to show a field. But unfortunately parent.id is not working, and: parent_id fails also. Any suggestions? EDIT: I shoudn't be so shortsighted. This works like a charm. Thank you @Robin S!1 point
-
If possible I want to have only one section of code for the output, as in reality it's a srcset with lots going on. Though I suppose with your example I could replace the <li> with an include. Otherwise I was wondering if I could build an array, but neither of the two examples below seem to work (the changed lines indicated by asterisks): edit: I had a typo, now it seems both examples below work! // Get images of the author if they exist if $page->images !='': $source = $page->images; // Otherwise get images of their book covers else: foreach($page->page_ref_for_their_books as $a_page): $an_image = $a_page->images->first; * $source[] = $an_image; * endforeach; endif; foreach ($source as $source): echo $source->size(100,100)->url; endforeach; Or: // Get images of the author if they exist if $page->images !='': $source = $page->images; // Otherwise get images of their book covers else: foreach($page->page_ref_for_their_books as $a_page): * $source[] = $a_page->images->first; * endforeach; endif; foreach ($source as $source): echo $source->size(100,100)->url; endforeach;1 point
-
I like repeaters for structuring data. For building a layout, not so much. I've seen the demo's on this forum of people using repeaters in creative ways to build a layout, but it never looks very intuitive to me. I've grown to dislike this approach so I've been looking at other content management systems for inspiration. Bolt CMS uses Article Editor, which is a nice (paid) javascript solution that's basically an advanced wysiwyg editor with support for grids and other nice features. I decided to integrate this into Processwire as an inputfield. Here's a demo: I created a few plugins for Article Editor that take care of uploaded images, inserting links and Hanna code support for adding dynamic bits to the editor. And the field also works in repeaters. You can pass your CSS to the editor so that the editor preview should look identical to the real page. I am using Bootstrap. A bonus of building a page this way is that the whole layout is stored in a single field so there should be fewer requests to the database compared to repeaters. Please note that since Article Editor is not free, you need a license to use it. I've been working on this module on and off for a while. There are refinements to be made, like perhaps loading the Hanna code previews dynamically (they are currently inserted into the editor after saving the page). Not sure if it would be good enough to release publicly but I thought I'd share it anyway because I'd like to hear if you think this is a nice approach :)1 point
-
1 point
-
The best thing I've had fun playing with recently is chaining in PW, and it's worth knowing about. Here's a good, slightly abstract example: On a large communal news website, an Article page has a PageField called Author - this links to the Author's page. The Author works for a Company - there might be several authors in that company writing on this website and you might be curious and want to find out various things like the following (pretend we're on the article page still): // Let's find all articles by this author: $author_articles = $pages->find("template=article,author=$page->author"); // Let's get the company name that this author works for - going through a few pages to get this one - from the article to the the author' page then the company page - all using the incredibly powerful PageField field type echo $page->author->company->title; // Ridiculously simple huh? // Now let's grab a list of other authors from this company - not sure why you would, but you could (the authors are all PW users in this case, so the template is 'users') $company_authors = $pages->find("template=user,company=$page->author->company"); // And finally let's get a list of all articles written by all authors in this company using $company_authors above $company_articles = $pages->find("template=article,author=$company_authors"); Now some people might wonder how the last one works - surely $company_authors is an object or array right? Well if you run a simple echo on it, it doesn't spit it's dummy out like PHP normally would, but rather gives you a concatenated list of page IDs in the format: 123|124|1024|456 - the pipe character is used in the last $page->find to mean "OR" so it works perfectly. And this is why I keep getting excited whenever I work with ProcessWire. I would need literally dozens of lines of code to recreate that example in any other CMS I can think of. I pulled in the articles and authors by template, but there are various ways of doing it and I just did it with template names as that didn't assume any particular site structure, so it's not necessary to follow that exactly. Have fun!1 point