-
Posts
720 -
Joined
-
Last visited
-
Days Won
3
Everything posted by froot
-
Inside the ProFields Table I have one column of type "select" for which I entered several options to choose from. How can I return these options? I mean loop through them to build my markup.
-
true. I missed that somehow, was more focused on the code. Anyways, that did the trick, thanks a lot, indeed dead simple ?
- 11 replies
-
- pagination
- get
-
(and 2 more)
Tagged with:
-
I have a similar issue, what I basically need is to reset the URL-segments, i.e. go back to the baseURL(?) without /page2 or above whenever the get variables change. Because when I'm on /page2 I and switch the search term, it won't find anything because the results I would get are not enough to require a pagination. You would think that something like this would be dead simple, but it's not. I don't even know what I exactly need to change. linkMarkup? urlSegment? pageNum? So here's how I tried to solve this now if ($session->what != $what || $session->letter != $letter) { $input->setPageNum(0); } $session->letter = $letter; $session->what = $what; I tried many different API commands, but they all won't work. Please help!
- 11 replies
-
- pagination
- get
-
(and 2 more)
Tagged with:
-
thanks for all your inputs, I figured out a way to not use AJAX at all. I'm using HTML hidden input fields and only change its value to be the clicked letter via javascript. Now I have no issue with the search field in the footer and the pagination works as well. <input type="hidden" id="hiddenletter" name="l" value="<?php echo $input->get('l'); ?>"> var letter; var hiddenletter = document.getElementById('hiddenletter'); var alphabet = document.getElementsByClassName('alphabet'); for (i = 0; i < alphabet.length; i++) { alphabet[i].addEventListener('click', setLetter); } function setLetter() { letter = this.id; for (i = 0; i < alphabet.length; i++) { alphabet[i].parentElement.classList.remove('active'); alphabet[i].parentElement.classList.remove('current'); } this.parentElement.classList.add('active'); hiddenletter.value = letter; } The only thing I'm still struggling with is the URL-segments. But that problem is discussed in this topic I need the URL-segments to reset when new get variables are being submited on /page2 and above. Not so easy…
-
any more advice here? Maybe another article where this issue is discussed? I am now trying to merge the AJAX loaded php file and the template itself and load the same search page (that uses the template) instead via AJAX. Pagination kinda works this way but now it also loads the header and footer inside the <div> that I declared to return the responseText, which is not what I want. Another issue I'm having is with the search field in the footer. The search-page with the search.php template handles everything with AJAX so far with no issue with URL $_GET variables. But the search field in the footer also loads this search-page and still adds a &q=searchterm to the URL which I can't get rid off via AJAX. To be honest, I don't mind not using AJAX, it would solve many problems if I didn't but I use another filter that is not built with input fields but instead with simple <a> tags and so it seems like there's no way around it (?). If I have to use AJAX, I wonder if there's not any native Processwire solution for AJAX-loaded search results instead of me having to find all these work-arounds.
-
the php is pretty straight forward, just a couple of foreach loops and if statements to render different markup for different search results. most of the php code is what's in the default search.php template anyway and the pagination is what is suggested in the documentation for uikit-markup. The interesting part is I think rather the javascript I wrote for the AJAX-call. window.onload = function() { var fetch = new XMLHttpRequest(); var letter; var radio = "AZ"; var temp; var what = document.getElementById('search-query'); buildRequest(); var AZ = document.getElementById('AZ'); var ZA = document.getElementById('ZA'); AZ.addEventListener('change', getRadioButton); ZA.addEventListener('change', getRadioButton); var alphabet = document.getElementsByClassName('alphabet'); for (i = 0; i < alphabet.length; i++) { alphabet[i].addEventListener('click', getLetter); } function getLetter() { letter = this.id; if (temp) {temp.parentElement.classList.remove('current');} this.parentElement.classList.add('current'); temp = this; buildRequest(); } for (var i = 0; i < how.length; i++) { how[i].addEventListener('change', getRadioButton); } function getRadioButton() { if (ZA.checked == true) { radio = ZA.value; } else { radio = AZ.value; } buildRequest(); } var submit = document.getElementById('submit'); submit.addEventListener("click", function(event){ event.preventDefault(); getRadioButton(); buildRequest(); }); var reset = document.getElementById('reset'); reset.addEventListener("click", function(event){ event.preventDefault(); if (temp) {temp.parentElement.classList.remove('current');} what.value = ""; letter = undefined; radio = "AZ"; buildRequest(); }); function buildRequest() { x = '?x=x'; // only cause it's easier to send each other variable with a leading '&' instead of building another if-statement if (what.value !== "") {q = '&q='+what.value;} else {q = '';} if (typeof letter !== "undefined") {l = '&l='+letter;} else {l = '';} if (typeof radio !== "undefined") {sort = '&sort='+radio;} else {sort = '';} if (fetch) { fetch.onreadystatechange = ReloadRequest; fetch.open("GET", "../_advancedsearch.php"+x+q+l+sort, true); fetch.send(null); } } function ReloadRequest() { fetch.readyState; if (fetch.readyState == 4 && fetch.status == 200) { var str = fetch.responseText; document.getElementById("results").innerHTML = (str); } } }
-
I'm building a search/index page. The php-code for the filters is located on the template-file and the pagination (MarkupPagerNav) as well. The php-code for the results however is on a php-file on the server, loaded when $_GET-variables (though not visible in the URL) are sent to the server via AJAX. I have an input field for a search term ($q), radio buttons to sort (A->Z and Z->A) and letters for alphabetical search. This all worked fine before I used pagination and URL-segments. The pagination is useless, each time I click on the next page button it renders the exact same results starting from top. I guess that's because it's not the template file anymore but the php file on the server and this one doesn't know anything about the URL-segments and pagination. What to do? Also, I probably will want to use Lazy-Loading instead of pagination in the near future. Any advice?
-
module SnipWire - Snipcart integration for ProcessWire
froot replied to Gadgetto's topic in Modules/Plugins
is it possible to put the custom fields on the product page instead of the snipwire-cart? I want the users to select product options right on the product page, however the custom-fields-feature of snipwire seem to only allow adding the fields to the cart and so they are not very prominent and might fall through in the checkout for some users. EDIT: I read above that it's already being considered, looking forward to it!- 233 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
hi all, is there a way to select pages by the first letter of their title? I'm trying to use that for an advanced search page. so on the frontend I put links for each of the 26 letters and one for numbers. When you click on one it sends this letter via AJAX to the server. Then I need to select the pages somehow of which the title starts with that letter. something like… if($_GET['letter'] != '') {$letter = $_GET['letter'];} else $letter = ''; … if (isset($letter)) { $matches = $pages->find("limit=0, title[0] == $letter"); } thanks for help!
-
I'm quite new to ProcessWire and never finished to learn new things about web development so forgive me if this is a stupid question. What is the exact advantage of this module to the native search function within PW? Because it feels like I could build on the "search"-template and get pretty much the same results.
-
I'm building an event-calendar with php, ajax and js. I want it to show a monthly overview when I click on a "month" button or when I switch the month. And show the events on one particular date when I pick a day. Also, most events are kind of exhibitions and so they have a start date and an end date much later, and occur on each day in-between as well. So on the template I put two date picking fileds date_start and date_end. Is there an elegant way to select the events using the API? Because right now I'm pushing around and storing the pages (events) in arrays, looping through them a couple of times, using the AJAX-variables in if-statements to compare with. It kind of worked already but showing the events on the dates between start and end as well adds another level of difficulty and I wonder if so many loops would be scalable. I tried: $items = $page->children->filter('date("Ym", date_start)=$y.$m'); doesnt't work XD Any advise?
-
Thanks! that pretty much does what I need it to do.
-
I was developing a site on MAMP and kept the content in a subfolder. Now that I moved it to the live server, I want to the content in the root folder or at least one folder up (not quite live yet). It seems to work fine for the frontend, no issues, but the backend's URLs still include the obsolete subfolder's name. I searched in many places, don't know how to change that. All I think to have figured out is how to change the default /processwire URL extension of the admin area, but not how to change i.e. remove its parent folder. Thanks for your help.
-
I'm using image tags in combination with UIKIT filters. So the image tags (predefined or user-entered) serve as filters. My site is in two languages though, is there an easy way to have this field in two languages?
-
OK thanks, I can live with that ?
-
changing the ID would make migration and finding files easier. I know that $page->id represents that ID and is set automatically when I create a page. I was just wondering, since I would enter a custom ID when creating a page, if I could overwrite this ID before or right after its creation.
-
is it possible to use subfolders like: assets/files/folder/subfolder/1234/image.jpg? is it possible to use a custom page ID? I guess I would need to create a field (e.g. with the name custom_id) for the template and then put something like… $page->id = $page->custom_id; thanks for you help!
-
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!
-
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?
-
Uncaught Error: Call to a member function width() on null
froot replied to froot's topic in General Support
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. -
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!
-
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 ?
-
@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!
-
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.
-
@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.