-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
Awesome! Yeah first! Now going to look at video.... Edit: Looks really great! Thank you for this preview! For sure very useful. Now my question. Would it be any way possible to have to be able define multiple "block" templates (with different fields each) for the repeater field? Then when adding a new item, it would ask for the block template to select first. Pretty much the same as it is now, just with variable templates. I can imagine it would require something complete different concept/codewise. It's just what I kinda "expected" from (the) repeatable page element, so I don't have to use child pages anymore. It can be very handy to be able to define "blocks" that can be chosen from, to build a page. TItle, Video, Text-Image, Linklist, Text. Do you see a good way to add such "variable blocks" feature to PW through a module, much similar like this one? Maybe they're also just invisible childpages that are editable and sortable via the parent page's block field. Just blah blah, I don't really know what all need to be considered. Have you implemented this repeater using hidden pages?
-
Only new file and copied over? Have you tried rewrite the line of code that causes the issue from scratch? You laugh, but I got an situation where it just wouldn't work with a selector, turned out there was a hidden char not visible at all even in "showinvisible" mode.
-
Strange as trying to track it down, I can't really tell why you get this error as to my understanding it isn't where it looks for if there's a "!=" in a selector string in PW. Here is the selector class: https://github.com/ryancramerdesign/P21/blob/dev/wire/core/Selector.php
-
elmr, I just tested for empty textfields in my local pw2.1 install, and it works fine. There must be something strange going on, like apeisa said. Edit: Maybe try a table database repair? Not sure what that error is all about. Waiting for Ryan is always the last resort Edit: Possibly also try to check if you got mal formed code, or any hidden chars. Even if you think its ok, it good to write new code in another file and try. The error suggests that you use a selector that isn't matched like "*=, %=, = ..."
-
yup it seems to work. ehrm paranthesis would be for things like ("body='no, I can'") ?
-
Just tested and it works fine in 2.2. Also if you use "youtube_id=, limit=10" you should use "youtube_id='', limit=10". Otherwise it assumes the limit is the value to be checked and won't work (in my local install) I don't think it's any different in 2.1. Would have to test. You can just use "youtube_id!='', limit=10" and it should work fine, I remember using it even in 2.1. Maybe Ryan got some more insights.
-
Edit: I think it's not possible Edit: or is it "color=null" ? Hmm
-
For text fields, yes color=0 will also work. [Edit: Maybe not the best one]. Thanks apeisa! I got another one also possible: $pages->find("color=''");
-
Ok, then Pete's example should work. Can you provide more informations what you're trying to do? What kind of textfield? Make sure there's really no value. Can you show some code?
-
Just wondering, are you using the ColorPicker module for this field? Just because you mention color as example. If that's the case it returns "FFFFFF" as default value, if nothing else yet saved. Considering it, it may not the best default value for a colorfield.
-
You mean why "$page->children()->children()" didn't work? ("$page->parent->parent" actually works to get the grandparent of a page.) Well it's simply that "children()" returns a 1 dimensional page array, so it works only with 1 explicit parent. As it would have to do a multidimensional page array which doesn't exists as far as I know. So a simple loop is needed here like diogo provided. Though I would do it with some check and a little simpler. Also there's a typo in the example of diogo. $channels = $pages->get(5766)->children(); foreach($channels as $channel) { if($channel->numChildren){ // has any children? echo "<h3>" . $channel->title . "</h3>"; foreach($channel->children() as $videopage) { echo "<p>" . $videopage->title . "</p>"; echo "<p>" . $videopage->videourl . "</p>"; // or whatever you need } } } Remember you could also add selectors to children("string"). Or if you want just to get all videos, you can use the ones diogo showed, but I'm not sure it will work or return a page array with only using "$pages->get("template=video")". I think something is missing, usually "get()" returns a single page. Following is the best method to use. You could limit it to the "Video" branch, so it doesn't need to scan whole site. $videos = $pages->get("/videos/")->find("template=video"); foreach($videos as $vid){ ... Or what I think diogo wanted to write is something like this. $videos = $pages->find("template=video"); But this will search through whole site structure. Something you might want to limit.
-
Thanks for bringing this up! Good to know, for sure something useful and needed in some projects.
-
Just tried again, and this time I turned on debug . Ok why didn't I do that before... idiot. Warning: Unknown: open(/Applications/XAMPP/xamppfiles/htdocs/.../site/assets/sessions/sess_529b6c6c041378cc9f28b165bf8bd0d3, O_RDWR) failed: Permission denied (13) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/Applications/XAMPP/xamppfiles/htdocs/.../site/assets/sessions) in Unknown on line 0 So it seems I've to set the permissions again. It's working!! Whow. What would you suggest setting the permission in this case on macos? Doesn't it change when I upload these folder to ftp?
-
Ryan, url is /processwire/ and when submited still same url. It does only show login error when I enter a false password. Really strange, it works great on real server, just not on my local one. I use XAMP, and got many PW installs working normal. I transfer files import db and the site is working normal, just can't login.
-
Nice work on this apeisa. I've looked at the code. Since I worked with the first incarnation of you shop module. It's good you simplified a lot and made it more structured. It's a shame I won't be able to use your new version in my current shop project as is, as my version now has some special features/functions I implemented, some of which are very specific to the project including product variation and multilanguage. But anyway good to see you progress on this, as I'm sure it will be also helpful to other people and projects. One thing that struck me is, why did you move some cart "functionality" to the checkout module? Like the cart form, update, remove stuff. Just wondering, as I got it tied with the cart and not the checkout process. To me the cart page, is still something that belongs to the cart and not the checkout process, but maybe I'm wrong here. I haven't got the time to go through all, but here's some I got implemented in the cart. Ajax: I got it progressively implemented in my shop, using jquery ajax and have the cart return json in case of an ajax product add. I ended up having the ready function like this: public function ready() { if (!($this->page->template->name == "sc-cart")) return false; // insert product if($this->input->post->product_id) { $product_id = (int) $this->input->post->product_id; $qty = (int) $this->input->post->qty; $this->addProductToCart($this->pages->get($product_id), $qty); // if requested through ajax, requested through script.js ajax call if($this->config->ajax){ $response = array(); $response['cart_count'] = $this->getCurrentCartCount(); $response['qty'] = $qty; $response['product_title'] = $this->pages->get($product_id)->parent()->title .", ". $this->pages->get($product_id)->title; echo json_encode($response); exit(); } else { // normal http request $this->session->redirect("./"); } } // update cart if($this->input->post->update) { $this->updateCart($this->input->post->items); $this->session->redirect("./"); } // remove item from cart if($this->input->get->remove) { $product_id = (int) $this->input->get->remove; $this->addProductToCart($this->pages->get($product_id), 0); $this->session->redirect("./"); } // go to checkout page if($this->input->post->checkout) { $this->updateCart($this->input->post->items); $this->session->redirect("../checkout"); } } "$this->pages->get($product_id)->parent()->title" As you can see here is something that comes from the variation implementation I got, it gets the title from the product from the parent page, as the variations are done through child pages. So I also got a function getCurrentCartCount(); to return total number of items in cart: public function getCurrentCartCount() { $sid = session_id(); $result = $this->db->query("SELECT items FROM {$this->className} WHERE status = 'in_progress' AND session_id = '$sid' ORDER BY last_modified LIMIT 1"); if($result->num_rows == 0) { return 0; } else { list($items) = $result->fetch_array(); $items_array = json_decode($items); $count = 0; if(!empty($items_array)){ foreach($items_array as $item) { $count += (int) $item->qty; } } return $count; } } Here's a sample of my ajax script that enables add to cart through progressive enhancement. // cart ajax progressive enhancement $('form.add-to-cart').submit(function(){ var cart_url = $(this).attr('action'); var prod_data = { "submit": 1, "product_id": $(this).find("input[name='product_id']:checked").val(), "qty": $(this).find("input[name='qty']").val() } $.ajax({ url: cart_url, type: 'POST', data: prod_data, datatype: "json", success: function(data){ // parse returned data string var resp = $.parseJSON(data); if(resp.qty < 1) { showMessage("success", "Der Artikel <b>'" + resp.product_title + "'</b> wurde entfernt."); } else { showMessage("success", "Der Artikel <b>'" + resp.product_title + "'</b> wurde Ihrem Warenkorb hinzugefügt."); } updateCartCount(resp.cart_count); }, error: function(data,status,error){ showMessage("error", "Fehler: Etwas ist falsch gelaufen. Artikel konnte nicht hinzugefügt werden. Error: " + error); } }); return false; }); To have the price being variable, I just had to adapt everywhere where it looks for the price or outputs cart stuff. I've done it so: The product ID will be always be one of the child pages. So either 1 or more variation. So even if it's a product with no variations, it is created via the main product page and at least 1 (the first) variation. This can simplify a lot, as it's always the same and only needs little adaption. // see if variant has price field // if not choose from parent page if($product->sc_prize) $total_price = $item->qty * $product->sc_price; else $total_price = $item->qty * $product->parent()->sc_price; $total_sum = $total_sum + $total_price;
-
I got smae problem with moved pw website to local server. I reset passwort and have same userAuthSalt, but I can't login. If I use the pw I've created it doesn't show any error, just stays on login page and I'm not logged in.
-
I got an WP installation for a friend on my host. I experienced already this kind of base64 encoded scripts at the end of the index.php's... I think it is related to this then, thanks for the infos. I will also have to take a look then. Sorry to hear you lost so much time on this. Glad you posted this here.
-
Oliver, that's pretty much how the current unfinished version apeisa coded works already. Product cart is saved in a custom table , once order completed the order gets saved as page under /admin/shop/orders/ with childpages as the products in the order. The template has a page field reference that is linked with the product. My current shop project bases on apeisa's start, and is pretty much still the same except I have variations. Only colors though, but I have solved it by having a "product-variation" template that presents the variable fields or any additional fields of the base product template. Then the product added to the cart will be one of these variations, the main product parent page then can serve for certain global settings. This allows for maximum flexibility in how to create products and variations. This needs some coding/pw skills to then adapt the template code for the different forms and some shop module code. But it's just me, I prefer this way of having control over code and setup while having some helper modules to help with certain common tasks. As for more complex variations with prize,color,size t-shirt example. Then the more usual way of having options as serialized data along with the main data like prize, product id, name would be required. I think having repeatable/flexible fields could be helpful here a lot. What you think? But still a simple setup with subpages and references could do this all and I like to be able to easily extend it and add thumbs for each variation and so on. It also is just a matter of having the cart helper support options serialized and building the right forms to add the products at the end.
-
Didn't you plan to implement bramus_cssextras plugin? I think it solve a lot of issues standard css select has. I think the behavior you get with the cleaning feature, its always been like this if I recall correctly and it is a mess. It will only remove tag styling like bold and em etc not classes set on elements. With the bramus plugin you don't get stacked classes and it let's you remove the class set easily.
-
Your welcome. Also if you want an admin page all users that have "edit" permission can see, you could just use: 'permission' => 'page-edit' , so no need to create custom role for that. But you're free to create one to have additional control.
-
Sure you can, but then you would require to do the "redirect" stuff in your search result rendering. For example each page that is in the result that has one of those templates, you want to output the parent url instead of the found page. $results = $pages->find("..."); foreach($results as $result){ if($result->template == "members" || $result->template == "events") $url = $result->parent()->url ; ... } But a nice side effect of using a php template with a redirect, is that if you edit a page and using "view" it redirects to the page it is listed. Without a php template you would have no "view" function anyway, but just to mention. Also notice, that repeatable page elements are on roadmap and will come pretty soon. But using sub pages is the way to go for now.
-
You can set the permission in the get module info of the process module. 'permission' => 'somepermission' just create a custom permission and add it to your editor role.
-
You could make the physical .php template of members and events redirect to their parent page where they're listed. $session->redirect( $page->parent()->url );