Jump to content

fruid

Members
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

2 Neutral

About fruid

  • Rank
    Jr. Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello all, what are the naming conventions of the image-folders in assets/files/1234/ ? Is there a way to customize the serialisation? many thanks!
  2. I managed to do an ajax call. On click it sends $_GET-variables to the server, generates markup (text and images) and then lloads it on the page. Everything works as intended. Now I'm trying to crop the images before loading (->size(450, 250)) but it simply dies when attempting to render images. Is that because the AJAX request can only load what's on the server and also rendering the images is just too much?
  3. OK here I go answering my own question. The image field might not be an array, but the pages that have this field are. So once there is a page on which that field is of empty value, the rendering process, as far as I can tell, dies. So when I use if ($item->image_field) {$main_image = $item->image_field->width(300);} it works fine.
  4. any idea why my image resizing/cropping doesn't work? everything works fine on the site when I use (in a foreach loop): $main_image = $item->image_field; but as soon as I try to crop the images or resize… $main_image = $item->image_field->width(300); $main_image = $item->image_field->size(300, 300); When I use either of these two lines (not both together obviously) I get an Uncaught Error: Call to a member function width() on null The image field is set to single image, not to array. Apparently the error is triggered upon rendering, because I don't even have to output the images to trigger the error. Also enabled cache on the page that uses this specific field but that didn't do it either. I'm currently working on several PW projects on my MAMP-localhost, resizing works for the other project (blank profile) but not this one described here (regular profile). Any advice? thanks for help!
  5. how do I return an array of children on which a certain boolean field is set to false? $pages->get("fieldname=false"); $pages->find("fieldname=false"); $pages->child("fieldname=false"); $pages->children("fieldname=false"); $pages->fieldname(false); … please help me stop the guessing 😄
  6. @huseyin thanks, that did it! Didn't read that earlier today. Getting there… But now I get an image problem like: Forbidden You don't have permission to access /path/to/site/assets/files/1062/ on this server. thanks so far!
  7. server log says PHP Fatal error: Uncaught Error: Call to a member function find() on null in path/to/test.php The AJAX request seems to work (I tried with echo "Hello World!") but the PW-objects, methods and functions and its API seem to not be recognised. I guess the test.php file needs to be in a different folder (I put it in the root folder) or I need to load another script where the objects and functions are defined.
  8. @huseyin yes I tried that to test if the array is working and it works fine. But I will need to request specific array positions via AJAX so I don't see how echoing the values would help.
  9. the more I think of it, all I really need is an array of the last level with some information of the above leve. So what I did is the following: <?php $allarticles = $pages->find("template=article"); // find by template of the last level $catalogue = array(); $i = 0; foreach ($allarticles as $onearticle) { $temp = array ( // create a temporary array for the lowest level 'id' => $onearticle->id, 'title' => $onearticle->title, 'coverimage' => $onearticle->cover->url, 'url' => $onearticle->url, 'author' => $onearticle->author, 'date' => $onearticle->date, 'year' => $onearticle->parent->parent->title, 'issue' => $onearticle->parent->title, 'offline' => $onearticle->offline, 'body' => $onearticle->body ); $catalogue[$i] = $temp; // add the results of each foreach (i.e. an array) to the main array at position $i $i++; // go to the next position of the main array }; print_r ($catalogue); ?> This seems to kind of work (though I don't know why I can only use print_r and not echo). The code is saved in test.php which is in the root folder. Now I'm trying to request this php file via AJAX. <script type="text/javascript"> var request = new XMLHttpRequest(); if (request) { request.onreadystatechange = ReloadRequest; request.open("GET", "test.php", true); request.send(null); } function ReloadRequest() { request.readyState; var str = request.responseText; document.getElementById("boxedcontent").innerHTML = (str); } </script> This script is at the bottom of the template file that is applied to a specific page. The code works when I request an html file but it doesn't work with a php file. I receive a "the server responded with a status of 500 (Internal Server Error)". Also, when I put the test.php inside the template file, the header and footer and whatnot is prepended and appended which is obviously not what I need, that's why I moved it to the root folder. Maybe then it lacks permission to access it? Thanks for help!
  10. so I basically have a 5-dimensional array. main page / level 2 pages // level 3 pages /// level 4 pages //// fields Here's what I have so far: $level3 = $pages->find("template=level3"); foreach ($level3 as $level4) { foreach ($level4->children as $thefields) { $level4_details = array( 'field1' => $artikel->field1, 'field2' => $artikel->field2, 'field3' => $artikel->field3, … ); }; }; I need to store all the $level4_details arrays in another array so I can json_encode it, request with ajax and further process with javascript. The above works alright in php but when I encode it to json, it only gives me the last of the last pages (level 4) because, I assume, with each foreach the array $level4_details is overwritten. I also need to have all the $level4_details arrays to be named after their parent so I can reference them properly. Thanks for help, a lot of this is probably rather general php than specific processwire understanding, help is therefore all the more appreciated.
  11. I'm pretty new to Processwire and AJAX so maybe this is not the smartest question (the answer could be easy though). What I want to achieve is to display images and onclick on an image (which are essentially pages) it should fill the markup below it with specific content of that page's children pages. By default it should show the first child's content (the newest one). This works fine. $category = $pages->get("/path/to/parent")->child; $subcategory = $category->child; $items = $subcategory->children foreach ($items as $item) { echo $item->title; // …and more code }; I understand that AJAX always requests a URL or file, usually JSON or XML. Is there a way to not request a specific file but to pass the contents of a PW-API-variable (in this case the children array) to javascript? Because what I'm trying now is to create an multidimentional array and convert that to a JSON file but that's not easy and I assume, or hope, unnecessary. Thanks for help!
  12. 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
  13. 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!
  14. fruid

    API not clear

    it works now. Your solution actually worked, there was another problem with the naming. thanks you all
  15. fruid

    API not clear

    tried that too, doesn't work. Notice: "Trying to get property 'url' of non-object …"
×
×
  • Create New...