Jump to content

Can

Members
  • Posts

    350
  • Joined

  • Last visited

Everything posted by Can

  1. Maybe this one helps https://processwire.com/talk/topic/7-new-markupcache-module/
  2. Thanks peterfoeng I think I already tried =, == and === and only with 1 = it´s updating, but as I mentioned before everything gets summed to one item no matter if it´s the right one. With 2 or 3 it´s not getting true?! So nothing happens. EDIT May I need to get the repeater page first to update it something like that 1. if(count($order->order_items)) { 2. foreach($order->order_items as $items => $item) { 3. $update_cart = $pages->get($item->get('id')); 4. $content .= $item->order_product->title; 5. if($update_cart->order_product = $form_addtocart[item]) { I don´t know, but what I really don´t understand is that line 4. gives me the right title (or ID of course) so it should only match if it´s the same but as I said before, it´s counting everytime on the same product in the cart no matter what I add?! I still think it should be something small because of my lack of knowledge...hopefully Cheers
  3. Hey guys, I struggled about half a week, okay wasn´t the only thing I´m on..but I´m not getting it. I´m working on a little page with a little shop, just a few books. Of course I know Apeisas shop, but it doesn´t support tax out of the box right now and I want to have the whole shop with cart and checkout on a single page and I had half of it already working with jquery but wanted to have something more scalable. While trying to get it on my own I´m digging more into php and PW Blabla I have a template called order. My plan is to store the cart in order page like "Cart 12.5.2014" and name it to "Order 12.5.2014" when checkout is completed. The choosen cart items are stored in a repeater "order_items" with fields "order_qty" and "order_product" (page fieldtype) Everything works fine. First time the customer is adding an item to the cart the system will create the page and add the product to the repeater. I´m storing an individual id in the session which will be the name (path) of the page so I can check if one is already existing and just add more items to it. Once the customer is ready and fills out the order form, the page gets updated his name and stores the address information and the id in the session gets deleted so the order is kind of locked. The only problem is, I´m not able to update the item list properly. Either each time the customer adds item 1 to the cart it creates a new repeater or it changes only the qty of the first and only repeater even when he adds another item to the cart Because I´m not a 100% sure what I´m doing it´s more like trial and error. This is my last working code where it´s updating the same repeater item every time if($input->post->addtocart) { $sid = $session->sid; $order = $pages->get("name=$sid"); $order_items = $pages->get("name=$sid")->order_items; if(!$sid) { $order = new Page(); $order->parent = $pages->get("/bestellung/"); $order->template = 'order'; $order->title = 'Warenkorb '.date("d.m.Y - G:i:s"); $session->set('sid', str_shuffle(session_id())); //str_shuffle to prevent problems when customer finishes an order and want to make another order $order->name = $session->sid; $order->save; } if(count($order_items)) { foreach($order_items as $items) { if($items->order_product = $form_addtocart[item]) { $items->of(false); $items->order_qty += $form_addtocart[qty]; $items->save(); break; } } } else { $order->of(false); $order_items = $order->order_items->getNew(); $order_items->order_qty = $form_addtocart[qty]; $order_items->order_product = $form_addtocart[item]; $order_items->save(); $order->save(); } } // end addtocart On the one hand, I´m understanding what happens. On the other I have no idea what´s going on. Maybe there are a lot of improvement possibilities on my code haha. Uh, I thought about customizing the events fieldtype to store the items, but I thought repeaters are easier for the beginning. Maybe tailored events field will be the next version of the shop. I really hope there is an easy solution for this "little" thing. Maybe I missed the right search terms. Cheers and a nice evening to all EDIT: Forgot to mention, that I know, that the "if(count($order_items))" is not a good way, because once there is an item in the cart it´s true And I already tried in_array() and array_search() but couldn´t get it working :-/
  4. Needed to change the rewrite code a little to get it work beside the shopping checkout from apeisa The second line (after <?php) looks now like this $get = $input->urlSegment1; if($get && $get !== "confirmation" && $get !== "payment" && $get !== "completed") {
  5. Fancybox didn´t work for me with jQuery1.11.0 used magnific instead <?php if($user->isSuperuser()) { ?> <script type='text/javascript' src='/wire/modules/Jquery/JqueryMagnific/JqueryMagnific.js'></script> <?php } ?> Thanks Soma for the tip!
  6. Yes thanks again It even provides a API function so it should be possible to automate it. But I wanted to have it even simpler with short links within the page And at the moment I don´t need to have external redirects
  7. Thank you Adrian should´ve mentioned that I knew this module but thanks anyway..maybe someone else would prefer the id solution ;-) I wanted to have the possibility to have readable shortlinks like example.com/tpls or /templates which would redirect to example.com/articles/templates for example Because the core module "Markup RSS Feed" works fine with my redirection stuff I don´t care about Markup Sitemap XML at the moment.
  8. I wanted to have a similar short link as mods.pw/XXX and wanted to store them directly in the page in a field. Created a unique text field "shortlink" This is my module code for creating a random key (in this case 6 digits) and assign it to the shortlink field <?php class ShortLink extends WireData implements Module { /** getModuleInfo is a module required by all modules to tell ProcessWire about them * @return array */ public static function getModuleInfo() { return array( 'title' => 'ShortLink', 'version' => 100, 'summary' => 'Pre-populate $field->shortlink with random 6 digit string', 'singular' => true, 'autoload' => "template=admin" ); } public function init() { // add before-hook to the inputfield render method $this->addHooKBefore("Inputfield::render", $this, "renderField"); } /** * If not empty, create unique value for textfield 'shortlink' * */ public function renderField(HookEvent $event) { $field = $event->object; if($field->name == 'shortlink' && $field->value == '' ) { // $id is unique, as page id is unique $shortlink = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@-_"), 0, 6); $field->set('value', $shortlink); } } } and then I activated URL Segments on my home template and added this at the very top of my head.inc if($input->urlSegment1) { // URL has /category-name/post-name/ $shortLink = $sanitizer->pageName($input->urlSegment1); $post = $pages->get("shortlink=$shortLink"); if(!$post->shortlink) { $session->redirect("/search/"); } $session->redirect($post->url); } It´s customized option 2 from Ryan (post #21) At the moment it seems to work as expected. But as I´m not really a programmer I don´t know if it´s really safe etc.. Maybe the code for the head.inc could come in the module? What do you guys think about this? Cheers Can EDIT: Added canonical metatag to the header I like that I´m able to override the generated key. The module is not really needed but it´s nice to have when I´m to lazy to think about an own shortlink When using for a customer I maybe set the field to read only, but because it´s unique text field it will throw an error anyway so shouldn´t be possible to mess with the field value Ah there is one thing I´m not sure about. The shortlink field is type of TextUnique, but what if the str_shuffle generates a duplicate (don´t think it´s impossible?!) I guess the field wouldn´t get populated right? Of course I could save the page for a second time but I´m sure there is a way of doing this directly while populating it for the first time in the module but I don´t know how? It´s currently not working with Markup Sitemap XML module, could extend the if in my header.inc to check for /sitemap.xml Ah just figured out that Markup Sitemap XML is not working with URL Segments turned on at all.
  9. haha don´t know if it´ll be worth publishing it..but we´ll see ;-)
  10. oookay you´re such a genius!! sounds like a plan..will definitely give it a try! Ah @Horst hadn´t had the time to try the image manager myself..what a shame UPDATE: You´re my HERO Kongondo!!
  11. @Neeks, good Idea. For me it´s nicer to float the images and have 3-4 in one row. @Soma, Interesting as well..never thought about putting images next to the body field or somewhere in a "sidebar" But I like to have those together and this way, with a widescreen display, it could be even better. Maybe i´ll just change the width of the whole backend..have it more fluid By the way, uhm kind of OT: Is there a way to have the new AdminTheme module as custom theme, like when I copy /wire/templates-admin to /site/templates-admin ? Because I would like to have this one as starting point for my admin theme. @Horst Yes you´re right, but we´re planning to settle somewhere tropical ;-) Thanks for the tip, I will. But maybe it will be another site which we are going to start in the next days..we´ll see
  12. wow that was fast and sounds logic will try it in a couple of minutes have to make some shopping first thank you soma! UPDATE: took a bit longer, because we just met a guy who will probably sail us to latin america It works like a charm..thank you Soma!!
  13. Thanks for the snippet. Just tried it out for learning purposes but I can´t get it working. First in the if($parent->child line is a closing bracket missing. As I´m not really into php it wasn´t to easy to find^^ So the form is showing up but whatever email I try it´s saying "You are already subscribed!" and I have no idea what to do. Ah, important to mention that I included head.inc and foot.inc and created the /subscriptions/ page. Is there anything else to do? Would nice to a have a little hint Cheers Can
  14. haha that's kind of funny ^^ thanks for "washing" my brain Can PW becomes nicer and nicer
  15. thanks for your detailed reply Wanze I don't want to prevent 404. I think I misunderstood totoff and thaught he wants to prevent 404.. I think I got it now, thank you Can
  16. Good morning guys Don´t really understand PW on this point. Am I understanding right that you guys mention to just set the status of the page or the parent to "Hidden: Excluded from lists and searches"? When I´m doing this on my test site the page is still accessible via the url, even when logged out. Only when I set the status to unpublished or delete the template file it´s throwing 404 As I understand right now, "hidden" does only hide from search results on the own page and on listings like navigations or something, right? But for this to be true. I just marked my contact page as hidden and pulled out some data via $pages->get('/contact') without including the "include=hidden" selector but it was still working. EDIT: okay $pages->get will include hidden pages as well as ryan said in this post And as I mentioned above, the page is accessible via url as well. (which I would understand because it´s only hiding from search results) And totoff is confusing me with this one #7 as well haha^^ Isn´t anything throwing a 404? I mean I could just add something random at the end of my url (example.com/somethingrandom) and getting a 404 So how can he (how can you) prevent it from showing a 404? Or are you doing a redirect? Hope someone can understand my confused brain and bring a little clarification in there which is really appreciated EDIT: At the moment I think it´s best for me to have a page without template file and set state to hidden to have it different in page tree list Cheers Can
  17. Thank you Horst And thanks for the tipp with Larzac, but I think we're not crossing france again.. I'm just porting the website www.deutsche-baeckerei-nerja.es to PW and will give the imagemanager a try have a nice day
  18. Good morning Ah, the existing image picker button in tinymce and the image manager module could provide those different sizes as well. Like the image manager a lot even that I didn´t tried it myself yet OT: I´m in the south of spain, cycling around the world with my girlfriend. If you´re interested, our blog is at www.globetrawter.tumblr.com Sometimes I would love when I were able to do something like this myself, but at the moment it´s not really appropriate to learn php and stuff^^ EDIT: As i mentioned before I´m not a PHP pro. How is it possible to check if an image is already inserted in tinymce or not? I think it would be great to have for example 1 thumbnail field. Throw all images in there. Pick those you want to show in the textarea (as in my post before, drag and drop the size) and leave all other images alone. All images left will be rendered as a little gallery below the text (or of course somewhere else) If needed you could even add a checkbox either to render the gallery or not (that´s the easiest part I know). The backend could highlight the images in the thumbnail field differently for those used in the RTE to have it even more fancy ;-)
  19. I knew that I forgot something^^ That´s the problem with my idea, I´m not a programmer myself. I´m happy that I can get some loops working I could help with the CSS hehe Offtopic: Gerade gesehen, dass du aus Aachen bist Horst, ich komme ursprünglich aus Berlin ;-)
  20. Hey guys, like PW a lot, thanks for that. Especially to Ryan ;-) At the moment I´m thinking about how to set up some sites. Then I came across this thread and actually here are some nice suggestions and ideas! The safest way is of course to not let the customers use images in wysiwyg fields and handle it via template output. But sometimes it´s just better to have images in RTE. Like the shortcode way, but as some others, I think it´s still to codey. I made a little mockup to illustrate my thinking What do you guys think about something like this: You have a thumbnail image field set up with some sizes After uploading a couple of images you get a view like in the attachment (it´s a bit messy I know..) Then you can just drag an image or grab directly a cropped one (just grab the name of the size) into the RTE The image is showing in the wysiwyg in the expected size It´s showing some controllers to set alignment and change size if needed First I thought about a little gear on the image, similar to Wordpress (?) but with a little dropdown for those settings. Okay it´s possible to show the dropdown on hover of course but it´s an extra way to get there and open it. But of course there is a lot of space to beautify this idea. And to limit the errors it´s only possible to adjust the image to the given sizes, so the designer is able to calculate any possibilities. Cheers, Can
×
×
  • Create New...