ai_slop
Members-
Posts
24 -
Joined
-
Last visited
Everything posted by ai_slop
-
So I tried the following but I'm not sure if it's good practice or not. Sharing in case anyone finds it useful. This setup requires that the PageImageSource module is installed with srcset image sizes setup in its config. It basically involves creating a page where cross-site images can be uploaded - like a simple image library. I created a short function to make it easier to grab the images where needed. Adding ->render() will output <picture> with srcsets. The media page should be set as hidden. Create a template, give it a name and add a multi-image field In the templates folder create _func.php and add the following: <?php namespace ProcessWire; /* Create a fn. that returns a Pageimage object from media library page you just created. Here i called my function medialib, and $medialibrary is the name of my template.*/ function medialib($filename) { static $medialibrary = null; if (is_null($medialibrary)) { // REPLACE the get directory with the Media Library page url created in admin. Mine was /media-library/ $medialibrary = wire('pages')->get('/media-library/'); } // Returns the image object if found, or null return $medialibrary->id ? $medialibrary->images->get("name=$filename") : null; } Add the include for _func.php in your _init.php in the templates folder: <?php namespace ProcessWire; // This makes the medialib() function available to all templates include_once("./_func.php"); // Render media library images on other pages using format: /*<?= medialib("imagefile.jpg")?->render() ?>*/ Function can now be called in template markup using: // Render media library images on other pages using format: <?= medialib("imagefile.jpg")?->render() ?> //Example <?=medialib("imageNameMustMatchFileName.jpg")->render()?> // Outputs <picture> tag. For CSS styling, target outer div class like so: .class img{.....} Combining this with another module might https://processwire.com/modules/process-media-lister/ might be useful.
- 1 reply
-
- images
- image library
-
(and 3 more)
Tagged with:
-
[WIP] Media Hub - the centralised hub for your PW media
ai_slop replied to Peter Knight's topic in Module/Plugin Development
Looking good, @Peter Knight! This is exactly what I was looking for. New to PW and building a portfolio site so quickly running into image management questions. I just posted a question on handling static or non-image field images - more specfically, how can we generate <picture> srcsets with PageImageSource when dealing with asset folder images. A solution without duplication would be nice. Not sure how relevant that is to your module but thought I'd share: Picture srcsets have to be the most tedious thing in html markup. I'd be happy to beta test the module if you like. Are you planning on releasing it as paid or open source? -
I've been reading through the forums for best practices on handling images on static pages - that's to say, how best to handle images in my static html markup when I don't have any need for image fields. On my current site, I have a lot of images on the home page and it seems silly creating an image field for all of these. Also, for pages where I do have image fields, I've been using the PageImageSource module to create wepb srcsets automatically (and it works great). I like setting my desired image sizes for the srcsets in one place, so I'd like to use this module for everything everywhere if possible. The problem is that it only works with PageImage objects, so I have to do something with my static images in order for the plugin to work with those. It looks like the media manager modules are not maintained. Could I just somehow put all my non-image field images in one page reference or something and have the PageImageSource module render those wherever they're needed? Could the following work? 1) Create an images/media page and template with images field. Set it to hidden. 2) // In _init.php: $media = $pages->get("template=media", include=hidden); 3) // on a template page markup: $desiredImage = $media->images->get("name=imageName.jpg"); .... <div><=?php $desiredImage->render()?></div> // renders the srcsets and <picture> tags with the PageImageSource module I don't know if this is the recommended way of dealing with <picture> tags for static pages (srcsets are such a pain to do manually!). Maybe there are some downsides to this that I'm not aware of. Any guidance would be very welcome.
- 1 reply
-
- images
- image library
-
(and 3 more)
Tagged with:
-
Looks great. New to PW here and have been scanning the forums for best practices on including images on static pages (no image fields). A media library seems to be the way... I wanted to understand how I might use the PageImageSource module to render webp srcsets on the fly for static images but was disappointed to learn that it can only be used with PageImage images. https://github.com/nbcommunication/PageimageSource I think ProcessWire would be a hard sell to many clients without some a full-featured image library solution, which is a great pity. The UI looks well done.
-
Using markup regions causes template to render twice?
ai_slop replied to jtborger's topic in API & Templates
Strange... I'm seeing some inconsistencies which seem at odds with what the docs say is possible, but maybe I'm going wrong somewhere... If anyone has any tips, I'd appreciate it! For example, in my _main.php and template.php I had: <main id="main-content">...</main> but content would not populate until I used pw-id: <main pw-id="main-content">...</main> I thought that both id and pw-id were possible? I've also had more luck adding scripts before the body tag using divs instead of putting the script tags within region tags for some reason. What worked for me: <div id="regionscript">...</div><!--#regionscript--> in the template instead of placing scripts within region tags. With an optional div in the _main.php: <div id="regionscript" pw-optional></div> -
Using markup regions causes template to render twice?
ai_slop replied to jtborger's topic in API & Templates
I'm having the same issue however the content is repeated 4 times. Building on the site-blank template and I haven't touched anything above the Doctype declaration, though there are existing variables mentioned below. Should those be deleted? I read the Markup Regions docs thoroughly though I'm at a loss here... Wondering if it's one of my scripts or something interfering with things. I have a GSAP typing text animation plugin before my closing body tag on a markup action region tag (on a template)... /** @var Page $page */ /** @var Pages $pages */ /** @var Config $config */ $home = $pages->get('/'); /** @var HomePage $home */ -
Very helpful, thanks. Haha yes Claude is very supportive 😂 Always try to verify if I can though while I'm learning. So it's a bit like function scope in JS then, the use keyword lets the function see outside itself. You've taught me a lot in this thread, cheers for that
- 7 replies
-
- beginner portfolio
- masonry
-
(and 3 more)
Tagged with:
-
Really appreciate your time, @elabx thank you. Out of interest, what are the benefits of using wire arrays over page arrays here? $images = new WireArray(); $project->section->each(function($images) use(&$images){ // should it be function($item) here, where $item is a repeater item group? $images->import($item->images->findTag("gallery")); }; I tried to get Claude to explain the code line by line but sometimes it doesn't get it right 😅 Did you mean function($item) instead of function($images)? - I'm assuming this like looks at each item in the section repeater like a foreach loop (?) - the use(&images) thing confuses me too. My guess is that it updates/appends the $images wirearray with the images inside the section items? it's just that use(&... thing I don't understand. Sorry! EDIT: So use(&$variable) allows the original $images variable to be updated directly, if i understand correctly.
- 7 replies
-
- beginner portfolio
- masonry
-
(and 3 more)
Tagged with:
-
Hi @elabx Thanks for your post. Your code looks clean but I'd like a little more flexibility ideally for my use case. I'd like the option to choose any image from my projects (not just the first). Also, sometimes I'll need to pick more than one image from the same project for display on the masonry gallery. For this reason, I'm thinking image tags might be the way to go but then the question is, how do I wrap that image in a link to its respective project page.. Page references seem like the way to go, but I'm still trying to wrap my head around how these work tbh. Custom image fields could also work but I'm trying to keep things as simple as possible. I also don't want to screw up alt fields for SEO and I'm looking to use PageimageSource to manage srcset and webp automatically (maybe I'm looking to learn too much at once for my first PW site 😂) https://github.com/nbcommunication/PageimageSource Assuming all image fields are image arrays with tags enabled in admin, could I do this?: // "sections" is the repeater on my projects pages that contain images and content. // "project_header" is a repeater in project template that contains project title and info. // Can I can use find() to get repeaters with template=repeater_repeaterName, like this? $projSections = $pages->find("template=repeater_sections, images.tags=gallery"); foreach ($projSections as $section) { $projectPage = $section->getForPage(); $title = $projectPage->project_header->first()->project_title; foreach ($section->images->findTag("gallery") as $img) { echo "<a href='{$projectPage->url}' title='{$title}'>"; echo $img->render(); echo "</a>"; } } It seems inefficient to me to have to parse through all project content repeaters for tagged images like this but maybe with caching it wouldn't be a problem? In my setup project title and description text is in one repeater, and all images are in another - not sure if that complicates things. I would like to wrap each image in a <a> that links to the respective project page.
- 7 replies
-
- beginner portfolio
- masonry
-
(and 3 more)
Tagged with:
-
Hello all, Another day, another thread! 😅 So I'm building out a portfolio site bit by bit, and trying to learn how ProcessWire works for clients in the meantime. Below is a screenshot of what a project page might look like. The project header is made with a project repeater and some txt fields. Below this is another repeater (sections) - that's where my project images live. What I'd like to make: a curated gallery page (like a photographer's portfolio page) where I can manually choose images from across my project pages to be displayed in a masonry style layout (e.g. like Masonry.js https://masonry.desandro.com/) I'd like to avoid duplication or double uploads - I'd like to reuse existing project images and keep my setup as fast/light as possible Clicking an image on the gallery should link to the related project Ideally without resorting to third party solutions - could image tags be used like an image reference? I've read a discussion on community requests for something like an image reference field (which would be great) but it looks like this isn't natively supported in PW yet: https://github.com/processwire/processwire-requests/issues/207 I'm wondering if I could use PW's built in image tags or something and then display all of those on a gallery page layout. But I'm not sure if I could grab the related project page links through tags alone? Fyi, I'm also using the PageimageSource module to keep things efficient. https://github.com/nbcommunication/PageimageSource Beginner here, so maybe I'm thinking about this the wrong way. Would be nice to hear your thoughts. Thanks!
- 7 replies
-
- beginner portfolio
- masonry
-
(and 3 more)
Tagged with:
-
What's the scoop on Repeaters. Should I be cautious?
ai_slop replied to douglas81's topic in General Support
Cheers for the info @poljpocket That's good to know. Thanks for your contributions to the community @bernhard I saw you created a lot of modules - I may try out RockCommerce at some point if I can get it to work with Stripe also. My site is likely to get image-heavy at some point so I'll probably cache it with one of the above solutions. I'm guessing caching mitigates repeater latency completely more or less on smaller/brochure sites? I'm not building anything too complex for the moment. Curious as to how well caching would hold up on a client store site of 100s of products though... -
Hello @LostKobrakai, did you ever get a masonry layout working with ProcessWire srcset images in the end? Building a portfolio site and scoping out some ideas. It looks like the new CSS spec for masonry layouts - or "css grid-lanes" will be a thing but it's not ready yet. EDIT: Just realised the OP posted in 2014 lol. In any case, readers might find this of interest: https://metafizzy.co/blog/imagesloaded-v5-released/ I may see if I can get it to work
-
What's the scoop on Repeaters. Should I be cautious?
ai_slop replied to douglas81's topic in General Support
Hi @kongondo Hope you don't mind me resurrecting this thread after so long. Using a repeater, I'm making a kind of section builder for a porfolio site. Using a radio toggle, it displays relevant layout fields to upload to for each section type. However they all use the same repeater. I'm wondering if there are any downsides or performance issues to including fields in a repeater, if they are not populated. My example only includes about 6 or 7 fields, with a project page using up a repeater about 5 or 6 times. Profields is out of my budget for this project right now, but I'm curious about any performance impacts my alternative may have. I've included screenshots of my repeater in the thread below. -
Thanks @monollonom I feel silly now 😅 I thought I had tried using values. I had used a round about way of getting the text values to work like an OR statement by elimination. I've updated to use numbers instead. Still not entirely sure why "section_type<=5" didnt work though. I've included what worked below in case other PW newcomers find it useful: heading section_type!=single_image, section_type!=two_images, section_type!=three_images, section_type!=txt_image, section_type!=image_txt section_type=6|7 text_area section_type!=single_image, section_type!=two_images, section_type!=three_images section_type=4|5|6|7 project_image_1 section_type!=txt_heading, section_type!=heading_txt section_type<=5 (doesn't work) section_type=1|2|3|4|5 project_image_2 section_type!=single_image, section_type!=txt_image, section_type!=image_txt, section_type!=heading_txt, section_type!=txt_heading section_type=2|3 project_image_3 section_type!=single_image, section_type!=two_images, section_type!=txt_image, section_type!=image_txt, section_type!=heading_txt, section_type!=txt_heading section_type=3 By the way, do you think using a large repeater in this way (like a mini page builder) is bad practice or performant enough? I know ProFields exists but I'm not sure how different this is performance wise
- 3 replies
-
- repeater
- field dependencies
-
(and 1 more)
Tagged with:
-
Thanks @virtualgadjo. The contentTypes tip looks interesting, though I'm not yet advanced enough yet to fully understand it, but I'll get there eventually! 😄 Ah yes @psy, I forgot about the <region> tags - good idea. I was just going to try something like <script pw-id='js' ...... pw-optional></script> but I'm not sure if that would work with prepending, before, after, etc and if the tags don't match. The region approach looks cleaner. Thanks!
- 11 replies
-
- 1
-
-
- markup regions
- template
-
(and 1 more)
Tagged with:
-
So I'm trying to create a little page builder of sorts for the project section of a porfolio site using a section repeater. The repeater includes fields for creating various section options to build out a page (1xfull-width screen image, image+txt, txt+image, 2ximages, triptych, etc.). I added a "section-type" radio field with layout options so I can use if statements in the code to change what markup will be created in the template. The screenshot below shows my repeater as it is now, but I'd like to use field dependencies to hide fields that are not required for the chosen layout type. The problem is - I just can't manage to get the "Show this field only if..." to work for partial text matches or OR statements. Taking the heading field as an example -- I only managed to hide the heading field with the following, and only for that one case: section_type%=heading_txt I tried using OR statements, but this didnt work either: section_type%=heading_txt|txt_heading Partial matching like this doesnt seem to work: section_type%=heading Am I missing something obvious? Would really appreciate any help. 1=single_image 2=two_images 3=three_images 4=txt_image 5=image_txt 6=heading_txt 7=txt_heading
- 3 replies
-
- repeater
- field dependencies
-
(and 1 more)
Tagged with:
-
Thanks @virtualgadjo, appreciate the advice. It's a little difficult at first (for a newcomer, at least) to wrap one's head around markup regions but it sounds flexible and more future proof than sticking with direct output and includes. You're right about the JS and animation overhead. That's the main thing that's bothering me. For my site, the homepage is animation and image heavy so I'm wondering whether I should just serve it as a static page without _main.php (with a few project thumbnail <a> tags thown in) and then use _main.php for the other pages. The idea would be to avoid cutting out bits of scripts from my existing static home page and putting them into templates for appendng - only to append them back in with markup regions. I guess serving home.php as the homepage wouldnt impact the URLs or anything
- 11 replies
-
- markup regions
- template
-
(and 1 more)
Tagged with:
-
Thanks again @monollonom. That helps a lot. Still trying to scope out what output stategy is best for a portfolio site I've built as static html, with possible a small store at a future date. I would like to ensure my GSAP scroll animations work properly so controlling JS and CSS from one working base seems better than using lots of include templates, Idk... Rather new to this. By the way, I had a look at your site. Your work is very impressive, well done. Did you build any of those sites with ProcessWire by any chance?
- 11 replies
-
- 1
-
-
- markup regions
- template
-
(and 1 more)
Tagged with:
-
Thank you, @monollonom. I suspected it was that but I wasn't sure. While I have you 😄 - If I use multiple base files like _main.php in this way, do I need to change anything in config.php or am I good? Thanks again.
- 11 replies
-
- markup regions
- template
-
(and 1 more)
Tagged with:
-
So in the Markup Regions output strategy, the docs seem to suggest that we can render markup using a different base to _main.php, for use on specific pages (like rss feed, homepage, etc) if needed. Have I understood that correctly? https://processwire.com/docs/front-end/output/markup-regions/ It says "we can do so by editing the template settings in the ProcessWire admin to use a different file, or no file at all, when appropriate. (This is found in Setup > Templates > [choose a template] > Files [tab])." I'm not sure, however, what setting I should change here. Let's say I want this template to apply Markup Actions to 'base.php' instead of _main.php, where would I set that here? Most of my confusion stems from the "Prepend" and "Append File" wording... I'd really appreciate any help 🙂 Thanks
- 11 replies
-
- markup regions
- template
-
(and 1 more)
Tagged with:
-
E-commerce recommendations with ProcessWire in 2026?
ai_slop replied to ai_slop's topic in Getting Started
@szabesz If the cart is only in session storage, would you recommend a JS approach over PHP or does it really matter? Yeah I had the impression that store builder modules were no longer maintained. I can't really see why - the cms itself looks promising so far... Thanks @Mikel Ya I came across RockCommerce but thought it was a paid solution... I guess it's MIT open source from now on? Your own Stripe Payment Links setup looks good. Do you still use it for single products/single subscriptions or have you moved to RockCommerce or something else? My use case is to sell design template files for download. Separately, global tax compliance looks like a pain with Stripe unless I pay serious $$$ for Stripe Tax. I saw with your solution that you can grab customer data from Stripe - does that negate any need for storing customer data in a database (hence avoiding data regulation headaches)? @elabx I did have a quick look at Shopify but for a side project (which may or may not work out) I can't really justify the monthly fees vs a pay-as-you-go model. Also, in that case I'm not sure why I would use ProcessWire at all if Shopify has its own cms features. Do they have a cheaper plan for just using their API with an existing site? Thanks everyone for the advice. -
Hi all, I'm evaluating ProcessWire as an alternative to Wordpress, and I'm curious to know what you are all using for your shopping cart and payments integrations. I have some front-end skills but I'm new to backend web-dev, so as a practice/hobby project, I'd like to setup a design template shop where customers can buy mockups for download. The more I look into this, it seems that it can cause a lot of global tax-compliance headaches, so I'm currently looking at lemon squeezy or something similar like a MoR, but I'm open to suggestions. As for Lemon squeezy, ideally I'd like to create a custom cart on my ProcessWire site (probably just using session storage) and only pass to LS for the final payment. Has anyone any experience with this? I've come across FormBuilder on here in relation to Stripe payments - can that be used as a shopping cart also? I could be wrong but ProcessWire seems to be short on modules similar to WooCommerce or e-commerce related tools (?) Would love to hear about your current payments integrations for 2026.
-
ProcessWire Commerce Features
ai_slop replied to kongondo's topic in ProcessWire Commerce (Padloper) Support
@markus-th Thank you! Ah, I should have looked more carefully - new here. Searching ProcessWire Commerce on google leads directly to this page so I wasn't sure if it was still active. I'll take a look at that, cheers. -
ProcessWire Commerce Features
ai_slop replied to kongondo's topic in ProcessWire Commerce (Padloper) Support
Has this module been removed or something? None of your links are working and there's no mention of ProcessWire Commerce on the Modules page... Am I missing something here?