Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

65 Excellent

About a-ok

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

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

  1. Thanks again, @szabesz for this! Made building it all in modules a lot more efficient and obvious now. Much appreciated.
  2. Thanks, this is really great and helped me loads. Is there a reason you use $config->paths over $config->urls?
  3. Thanks all. I ended up using wireRenderFile() for all the includes. Is this a more preferred way?
  4. I apologise in advance if this is more a 'PHP' issue than a 'PW' issue. I have an include in one of my templates: foreach ($query as $item) { include('./inc/item__project--filter.inc'); } And within this include I have another include (as I tend to build in re-usable modules): include("./slider__v--horz.inc"); Both includes are within the `/inc/` folder within templates. If I visit this page then it all renders fine, but when I use an AJAX request to render the first include (when the selector for the page changes), it returns an error: PHP Warning: include(./inc/slider__v--horz.inc): failed to open stream: No such file or directory in .../www/lucent-lighting/inc/item__project--filter.inc:10 On the template that both these includes are being used (projects.php) I am executing the following check with the AJAX request (GET) is fired if ($this->input->get->action == 'filterEndpoint') { $inputExists = $this->input->get->inputExists; $filterEndpoint = $this->input->get->filterEndpoint; if ($this->input->get->pageTemplate == 'projects') { if ($inputExists !== "") { // $query = $pages->find("template=products-filters-single, products_filters_projects.count>0, include=all, sort=sort, {$filterEndpoint}"); } else { $query = $pages->find("template=projects-filters-single, projects_filters_projects.count>0, include=all, sort=sort, {$filterEndpoint}"); } $itemTemplate = './inc/item__project--filter.inc'; //bd($query); } $output = ''; foreach ($query as $item) { $output .= wireRenderFile($itemTemplate, array('item' => $item, 'inputExists' => $inputExists)); } return json_encode(['html' => $output]); } Any thoughts?
  5. Thanks. I can't get it to work but my $config->urls->root is "/jamb/" as I am working locally (and my dev server has a similar setup) of sub-folders (root > each project). Would be good if we could amend this regardless (maybe on the roadmap?) but thanks (and @adrian too) for the explanation. Re the hook onto 'getItemString' – I'm actually using this to concat an item... for some reason I didn't think to use it to alter the item itself. So that works.
  6. I could just do this within the template rather than as a hook. But the URL would still remain as the href and it’s a bit confusing. So currently there’s no way to hook into the full URL?
  7. Do you mean a `$session->redirect()`? Hmmm...
  8. I thought so too but all I get is `https://local.dev/jambhttps://www.hawkerantiques.com` Maybe it's related to `MarkupSimpleNavigation` EDIT: It's not... it happens with normal `$page->url` outputs.
  9. You mean something like this? wire()->addHookMethod('Page::customUrl', function($event) { $page = $event->object; if ($page->products_categories_external) { $page->url = $page->products_categories_external } else { $page->url = $page->url; } }); The issue is I'm using `MarkupSimpleNavigation` (so normally I'd just write a check) which is why I was thinking a hook that would modify the URL.
  10. I'm aware you can change the path of a path by hooking into `Page::path` but I need to amend the URL rather than the path (change it to an external URL that's in a field on the page). $pages->addHookAfter('Page::path', function($event) { $page = $event->object; if ($page->products_categories_external) { bd($page); $event->return = "$page->products_categories_external"; } }); Any thoughts?
  11. I've got some AJAX filtering going on – when the user selects a 'filter' it'll send an AJAX request to a ajax.php template and fire the following: $filterEndpoint = $this->input->get->filterEndpoint; if ($this->input->get->pageTemplate == 'projects') { $query = $pages->find("template=projects-filters-single, projects_filters_projects.count>0, include=all, sort=sort, {$filterEndpoint}"); $itemTemplate = './inc/item__project--filter.inc'; bd($query); } $output = ''; foreach ($query as $item) { $output .= wireRenderFile($itemTemplate, array('item' => $item)); } return json_encode(['html' => $output]); I have an include to a functions.inc file that has a getRatio() function that is included at the top of every template file. The issue is upon selecting a filter I get a `Call to undefined function getRatio()` error. I have tried to use include_once to the functions.inc file but doesn't seem to make a difference. Any thoughts?
  12. Just an update. This is my current (updated) code. The `$shopifyShop` stuff is related to the Shopify API. I have a 'currency select' element which the user can use (initial check). $shopifyShop = $page->shopifyShop(); $shopifyShopCurrency = $shopifyShop['shop']['currency']; if ($this->input->post("region")) { $session->set("shopifyShopCurrency", $this->input->post("region")); } else { if (!$session->get("shopifyShopCurrency")) { $ipapiCurrencyCode = $page->ipapiGetUserLocation()['currency']['code']; if ($ipapiCurrencyCode && $ipapiCurrencyCode !== 'GBP') { $session->set("shopifyShopCurrency", "ROW"); } else { // Set it as the Shopify store default $session->set("shopifyShopCurrency", $shopifyShopCurrency); } } }
  13. Thanks for the lengthy reply! Yes I guess you're right! Storing it in a $session variable is sort of caching it (so if the user is in session then it won't need to check the ipAPI again) but I get your point about storing it as a variable initially to prevent the double call if not. Totally. I have since removed this after giving it more thought. Yes sorry I am using it throughout the templates – this is just my initial check
  14. Okay thanks. So can we confirm that even though ready.php is called on every page load (back and front) it will only run the hook when told to in my templates? It won't run when someone is on the backend for example?
  15. It should be, no? If `$session->get(“shopifyShopCurrency”)` doesn’t exist then it stores the ipAPI call in it so it should skip the API call next page visit within the session...
  • Create New...