Jump to content

cb2004

Members
  • Posts

    550
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by cb2004

  1. I have creating a website that reads an XML file to pull in products (pages). When a product is out of stock in the XML file, this page becomes unpublished. I want to display a different 404 message to what is usually seen if a product is unpublished and was just wondering the best way to go about this? Or would the best thing be to set it to hidden, and then check if the page is hidden on the template level and do the logic there? Cheers.
  2. That did it, options field and ("sort=dropdown, sort=price")
  3. Ok it got a bit more interesting. Text could have Available, Coming Soon or Not Available with prices. I want them to appear like: Available sorted by price Not Available sorted by price Coming Soon sorted by price Easily done with 3 foreach blocks but was just curious.
  4. Hi all, hope everyone is well. So, I want to return the results where the text field matches 'a' and sort those by 'price', then display the results where the text field matches 'b' and sort those by 'price'. Is ProcessWire capable of this or do I just need to do a couple of foreach?
  5. Is cache set on the template used for internal pages?
  6. Ah, I see what you mean now Sebii, your solution looks like it would work perfectly. I will report back when I get round to building the search. Thanks.
  7. Yeah, I always find a text field as a search an odd one, is the user expected to know what to search for. But thats what the client wants. There is also no textarea fields for the products which means its harder to search for keywords. I think my idea could work, so the user would type in "red" as their search and any products with "red" in the field search_tags would show up. This fields data could be: red, blue, small, large, manufacturer
  8. I haven't used the search in ProcessWire yet, but I have a project coming up that will require it. It is kind of an ecommerce setup where the product has options like manufacturer, colour, size etc. These are managed by the client using a page structure of: - Options - Manufacturers - Manufacturer - Manufacturer When a product is added these options are then selected using page selectors. On the site there is a requirement for the search field (text), however I am thinking as the options will not appear in the actual product data (red, blue, small, large), they will just be id's to relate to the pages, the products will not appear in the search results. So my thought process is this, hook into save and populate a text field with csv (Search tags) all of the text from the selected results e.g. red, small, then when somebody searches for red, the products will appear. Does that sound like the best way?
  9. Ben provided the correct hook here: https://github.com/ryancramerdesign/ProcessWire/issues/1832 So we end up with: $pages->addHookBefore("ProcessPageEdit::processInput", function($event) { $page = $event->object->getPage(); // apply job title if a quote is selected, apply customer address if customer selected if ($page->template->id == 48) { if ($page->page_quote && empty($page->title)) { $page->setAndSave("title", $page->page_quote->title); } if ($page->page_customer && empty($page->textarea_1)) { $page->setAndSave("textarea_1", $page->page_customer->textarea_1); } } });
  10. This is what you have to love about ProcessWire. Fantastic release last week, some feedback from users, then an even better release 7 days later. 2 small requests from me. Tooltips/titles for the icons for the different views. Reset to default for the slider. Keep up the great work team.
  11. I am building a system which has a page selector using the template user. When the page is added I wish to autopopulate the page_user field with the logged in user, but they can also change this should they wish. This doesnt seem to work: $pages->addHookAfter("added", function($event) { $page = $event->arguments(0); if ($page->template->id == 57) { $page->setAndSave("page_user", $user); } } I have also tried numerous other things like $page->page_user = $user, and lots of variations but no joy. What does actually work is something like $page->setAndSave("page_user", 41); so its not reading the logged in $user, even if I do something like $user->id. Any help would be appreciated. Cheers.
  12. Fantastic module. Thank you.
  13. I am using hooks to populate some required field values. The populating is done, but I get an error message if it is a required field regardless if it has been populated. Which hook should I use to save the values, then the page displays without an error? Cheers. $pages->addHookAfter("save", function($event) { $page = $event->arguments(0); // apply job title if a quote is selected, apply customer address if customer selected if ($page->template->id == 48) { if ($page->page_quote && empty($page->title)) { $page->setAndSave("title", $page->page_quote->title); } if ($page->page_customer && empty($page->textarea_1)) { $page->setAndSave("textarea_1", $page->page_customer->textarea_1); } } });
  14. I could be wrong but I think LostKobrakai edited his post from $page->text_1 = "test"; to $page->setAndSave('text_1', "test"); as I revisited his solution and it worked fine.
  15. I have a working solution. I am taking a guess that it cannot update a field directly in the page you are saving without a bit of extra information: <?php $pages->addHookBefore('added', function($event) { $page = $event->arguments(0); if ($page->template->id == 46) { $p = wire('pages')->get($page->id); $p->setAndSave("text_1", "test"); } }); The solution by LostKobrakai works as well.
  16. I tacked on $this->message("WORKING"); just to make sure I got this message and I did.
  17. Cheers LostKobrakai. Still no joy with this though.
  18. This is in the ready.php file, I think it would work with no problems on the frontend.
  19. Cheers BitPoet, but there is an error after adding: Method Pages::setAndSave does not exist or is not callable in this context
  20. I am having a bit of a brain ache with this one. Can anybody point me in the right direction. At the moment I just want to get the field text_1 populated with the value test and then I should be good to go. Cheers. <?php $pages->addHookAfter("added", function($event) { $page = $event->object; if($page->template->id == 46) { $page->text_1 = "test"; } });
  21. VPS does look great, but it is a page selector. My idea was an image/file selector outside of the RTE. The functionality to add images/files from other pages is an easy process and available in the RTE, but not in an image/file field.
  22. Seems like this would be a nice addition. I have also just come up with a need for this for files as well. The file already exists on another page but I can only select the file from the RTE (but I want to add some styling and a font awesome icon), but I want this to be selectable from a field.
  23. Yeah, I have been caught out with classes starting with digits a few times. I will look into adding a data tag as you suggest. Cheers.
×
×
  • Create New...