-
Posts
715 -
Joined
-
Last visited
-
Days Won
3
Everything posted by froot
-
I have an array of pages and each page has 6 subpages. How do I select a specific field of one of the subpages? I'm trying to output the image of the last subpage on the top parent page. So far the only thing that works is to output the image of the first subpage with… $years = $page->children; foreach ($years as $year) { echo '<img src="' . $year->child->cover->url . '"/>' //cover is the single-item image field } the subpages are always titled (an listed) as 06 05 04 03 02 01 But I want to output the last child which would be 01. Should I first sort it by title and store in another array? I tried that to no success. How to use a selector? Something like this? $years = $page->children; foreach ($years as $year) { echo '<img src="' . $year->child('title=01')->cover->url . '"/>' //cover is the single-item image field } Doesn't work. What am I not getting? thanks for help
-
module SnipWire - Snipcart integration for ProcessWire
froot replied to Gadgetto's topic in Modules/Plugins
I am using the SnipWire module which essentially seems to work fine so far. The following is what I need, using breadcrumbs to illustrate: shop > product category > products In the SnipWire demo content, clicking on "categories" in the nav I get categories, but those are categories of posts, not products. Clicking on "Snipcart Shop" in the nav I get products, no categories. I actually have created my own work-around with pages and subpages, copying most content of the templates snipcart-shop.php and snipcart-product.php (so to not touch the original files) which seems to work fine for the most part – more to that later ? However, in the product template you can choose "The categories for this product". I guess that would make more sense, maybe even be beneficial for SEO and whatnot. But when I choose any given demo category, it's not listed in that category. Like I said, that only works for posts. The category template fetches the posts like so: $posts = pages()->get('/blog/')->children("categories=$page, limit=10"); Just changing this line of code to fetch its children instead is probably not the most elegant solution – since the products can be assigned to a category, I assume there must be a way to make use of that. Thanks for help!- 231 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
it works now. Your solution actually worked, there was another problem with the naming. thanks you all
-
tried that too, doesn't work. Notice: "Trying to get property 'url' of non-object …"
-
thanks for your clear explanations. However, it doesn't work. First of all, I only wanted a single image field (I now figured out how to set it to be a single field, namely under fields>details>formated value set to single item). I also now removed the overrides of that field within the template. So I don't need to loop through the images alright, but I do have to loop through the "entry"-pages, the code being on the parent-page. Here's my code $entries = $page->children; echo '<div><ul>'; foreach ($entries as $entry) { echo '<li><a href="' . $entry->website . '">'; //was $entry->domain echo '<img src="' . $entry->logo . '"/>'; echo '<strong>' . $entry->title . '</strong></a></li>'; } echo '</ul></div>'; The only thing that is put out is the title. Might the issue be the mixed quote marks? thanks for your help! EDIT: my bad, the <a> link works fine, I removed the override but forgot to change it in the code ? (see comment above)
-
hello, I have a template with two image-fields, one with label "logo" and the other one with label "coverimage". When I put $entries = $page->children; foreach ($entries as $entry) { echo $entry->images()->url; } on the parent page, PW seems to output the path of the images. How do I output the image from either field specifically? I find the API a little bit confusing… $fields->find("selector") $fields->get("name") //do I replace 'name' with the field's label? $fields->get("selector") //or 'selector' with the field's label? $field->name //does that output the field's name? where do I specify an image field's name, afaik it only has a label. Or do I replace "name"? $field->label $field->get($key) //what is $key? And how do I go from here to output the url? What am I not getting? Is there a shortcode to just renders HTML with the image inside?
-
module SnipWire - Snipcart integration for ProcessWire
froot replied to Gadgetto's topic in Modules/Plugins
thanks, went for a new installation with "regular"-profile and it worked out fine.- 231 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
module SnipWire - Snipcart integration for ProcessWire
froot replied to Gadgetto's topic in Modules/Plugins
Hello, I'm also getting this kind of error Uff da… Fatal Error: Uncaught Error: Call to undefined function ukIcon() in site/templates/snipcart-shop.php:45 #0 wire/core/TemplateFile.php (318): require() #1 wire/core/Wire.php (380): TemplateFile->___render() #2 wire/core/WireHooks.php (823): Wire->_callMethod('___render', Array) #3 wire/core/Wire.php (450): WireHooks->runHooks(Object(TemplateFile), 'render', Array) #4 wire/modules/PageRender.module (536): Wire->__call('render', Array) #5 wire/core/Wire.php (383): PageRender->___renderPage(Object(HookEvent)) #6 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array) #7 wire/core/Wire.php (450): WireHooks->runHooks(Object(ProcessW (line 45 of site/templates/snipcart-shop.php) This error message was shown because: site is in debug mode. ($config->debug = true; => site/config.php). Error has been logged. I installed SnipWire to my best knowledge, did the additional steps, created a SnipCart account, generated the public and the secret API key which I put in the module's settings, installed the product Snipcart products package, just not necessarily in that order. The only thing I didn't do is to set up the domains cause I'm working on the MAMP server I also downloaded the _uikit.php clone from github as suggested by @dragan but I don't know how to install that. So how to install that or is there another way to fix solve this issue? Also, is there an alternative shopping module to snipcart because my requirements are very primitive. Just buying a product, no insights, no stats, no fancy stuff like "clients also bought" and whatnot. Really just a shopping cart, enter shipping and billing address and then checkout with paypal. Maybe a confirmation email. thanks for help!- 231 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
I need the following structure of pages and subpages. A > B > C > D What I mean is A is parent of B which is parent of C which is parent of D. PW basically does exactly what I need in terms of structure, no need to code anything yet. However, this is where I need some adjustments. Each D is assigned an image and all the D should be listed on the C-level along with the D-title and other fields. Each C is assigned an image and all the C should be listed on the B-level along with the C-title. Each B is assigned the image from its first child and all the B should be listed on the A-page along with the B-title. I tried my own work-around with variables and arrays but I can imagine this to be much easier to do since PW natively almost does exactly that, except for the images. I guess it's a quite basic requirement, like posts with thumbnail or "featured image" (pardon my WP analogy). Also, as of now, my code to accomplish this is not attractive at all, it's the usual mix of html and php, maybe there's no way around this but also maybe there's just a simple API line that would kind of render what I need with not much work-around. Furthermore, the D can be viewed on the site but they are essentially products that will be sold on the site once I have a simple shopping cart module up and running. My question here is, should I start with the shop function and the products can be viewed as described above or should I start building the page structure as described above and add the "add to cart" function etc around that? Last but not least I'm also confused how to even select a specific input field's value. When I use echo $somevariable->get("images")->url; it works fine. But what if I have several input fields, How do I select one specific field? Is it whatever I labeled it with in the template settings? because… echo $somevariable->get("cover")->url; doesn't seem to work… Thanks for your help. fruid
-
thank you very much! it's good that you mention that cause beginners like me might think there's something evident and totally logic that they are not getting when in fact they should just use trial and error like more experienced PW developers apparently do as well. I actually managed to the get it to work the way I wanted now.
-
Hello beginner here and therefore very basic questions. I have a template for a child page and on that there's an image field. How to I output that image on a parent page? it must be something like echo "<img src='" . $page->children->image->url . "'/>"; How does the script know which field to take the input from? Is it whatever I put in "label" when I added the field to the template? When do I use "pages" as opposed to "page"? When do I use "children" as opposed to "child"? when do I use "->" as opposed to brackets? When do I use "get" as opposed to "render" or just nothing? Obviously there's something very basic I'm not getting and those things always seem not worth explaining on the internet so please someone explain it to me or push me in the right direction. Appreciated! fruid
-
Hi, yes I used Menu Builder instead, does pretty much what I need. Thanks a lot though. Fred
-
I'm trying to put pages in the main menu on condition that the checkbox, a field named "menu_item" that I created, is checked on that specific page. so in the _head it says: foreach($children as $child) { if($child->id == $page->rootParent->id) { // this $child page is currently being viewed (or one of it's children/descendents) // so we highlight it as the current page in the navigation echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span><a href='$child->url'>$child->title</a></li>"; } else { echo "<li><a href='$child->url'>$child->title</a></li>"; } } so I figured I add elseif($page->child($menu_item) == 1) { echo "<li><a href='$child->url'>$child->title</a></li>"; } but no matter how I twist and turn it it doesn't work. Is is $page->child($menu_item) or $child->menu_item or $page->child->menu_item or … thanks for help Fred
-
OK, I'm getting the hang of it, it's indeed quite flexible the way it is. Thanks for your help, stay save, Fred
- 7 replies
-
- permissions
- blank page
-
(and 1 more)
Tagged with:
-
so I need to code the template as php and html after all? I thought it was supposed to be easy to use. And after coding the template and all I still need to select the fields that I want to add to the template in the admin panel after all? Isn't that redundant?
- 7 replies
-
- permissions
- blank page
-
(and 1 more)
Tagged with:
-
Hi, this is the first time I'm using ProcessWire. I thought I get how fields, template and pages work, but when I create a template in the CMS, it doesn't generate any file in site/templates/ Then I thought I might need to create a blank file myself manually on the FTP (which already seems odd to me). Once I did that, I tried to add fields to the template but again, doesn't write to the php file. When I create a new page and apply said template to it, the page stay blank. AFAIK the mod_rewrite of the apache is on and I went for the worst case scenario described here https://processwire.com/docs/security/file-permissions/ and set all file-permissions for future files to 0666 and folders to 0777 in the config.php What am I not getting and what am I doing wrong? Help is appreciated, stay save everybody, Fred
- 7 replies
-
- permissions
- blank page
-
(and 1 more)
Tagged with: