Jump to content

Guy Incognito

  • Posts

  • Joined

  • Last visited

Everything posted by Guy Incognito

  1. Interesting - I did try to call setLocation() from ready and init and both threw an error even though the blog post indicates they’re callable from there.
  2. That was my first thought too but it seemed to produce different output when bootstrapped vs loading as ‘native’ ProcessWire. Although I’ve now solved it, my hunch is still the rewritebase option in htaccess wasn’t working as intended. It could be because of the NGINX Apache proxy setup. For the record since I left the office for the day it dawned on me that the link @wbmnfktr posted above to Ryan’s updates on the customisable paths probably will work - but I think it may currently require the dev branch whereas this site is running master.
  3. Ah ha moment - I think I got it! Setting the root url in the template seems to have solved the issue. Although I think as per your post @wbmnfktr there's possibly a less destructive/repetitive way to this in future if can get my head round it! <?php $config->urls->root = '/pw/';?>
  4. Thanks @wbmnfktr - I did take a look at this and couldn't get anything working. I'm not sure at this stage if this is a server config issue my end or I'm not using ProcessWire as intended in this scenario. It seems to me that PW is grabbing site root from the parent page where the embedded bootstrap content is rather than the PW installation itself. Is this expected behaviour?
  5. Have read loads of similar threads but can't find the deifnitive answer. I'm bootstrapping ProcessWire into a Magento installation. Everything is working fine in terms of expected PW API functionality, however I cannot get the paths for images in the site work correctly. ProcessWire is installed in a subfolder called 'pw'. If I load the PW site directly e.g. visit mainsite.com/pw everything loads fine and all image paths are correct. If I load the parent site in the root folder with the PW bootstrapped page content rendered within it, the image paths don't contain the subfolder and so are broken. So I get https://mainsiteexample.com/site/templates/img/test.jpg instead of https://mainsiteexample.com/pw/site/templates/img/test.jpg I've tried updating the rewrite base in the .htaccess file but it doesn't seem to make any difference. Have also tried various settings in the config file to no avail. Wondering if rewrite base perhaps isn't working as intended because I'm behind a NGINX/Apache hybrid environment?
  6. Thank you - I knew I was doing something stupid... burning the midnight oil!
  7. I've created a simple sports league fixture generator in a template called 'League'. Teams are added as page references then a fixture list is created as a ProFields table by hooking page save to add new rows to the table. The bit I need help with is that I'm trying to check a fixture doesn't already exist before adding it to the table (e.g. if a new team is added to the league). I'm trying to do this with a PW selector to filter the fixtures table and check whether Team A vs Team B already exists in the table. Then on the next line checking no fixture was found by using count(). However as soon as I add the selector the script no longer adds any rows to the table. If I take it out, it all works fine (albeit with duplicate fixtures each time the page is saved). I've also tested the selector in a page template and it filters as expected. It's late here (UK)... I'm probably doing something stupid! Any ideas? <?php //Hook page save to generate league fixture lists $wire->addHookAfter("Pages::saved(template=league)", function ($event) { //Get which page has been saved $page = $event->arguments(0); $noFixturesAdded = 0; //For each team in league cycle through and add home fixtures foreach ($page->teams_in_league as $teamA) { foreach ($page->teams_in_league as $teamB) { //Check if fixture already exists $existingFixtures = $page->fixtures("team_a=$teamA,team_b=$teamB"); //Check team A is not the same as team B as you can't play yourself //Then add row to fixture table if ($teamB != $teamA && $existingFixtures->count() < 1 ) { $fixture = $page->fixtures->makeBlankItem(); $fixture->team_a = $teamA->id; $fixture->team_b = $teamB->id; $page->fixtures->add($fixture); $noFixturesAdded ++; } } } //Save updates to table $page->save('fixtures'); $message = "League saved. $noFixturesAdded new fixtures were added"; $this->message($message); });
  8. Thanks @Ralf - can confirm this solved the title issue. Still had some issues with importing multiple page refs which I worked round with a quick custom JSON import script, but good to know can use this import going forward.
  9. Hi @Ralf - thanks for this - completely missed Reno's note but this sounds like my exact issue and will try it out today.
  10. Is it possible to import users with this module? When I try I get the error Unable to import page because it has no required 'title' field or it is blank. If I add a title column to the CSV it doesn't show on the next page. I simply get a 'title' select field to map it like the other field but no title field shows in the in the dropdown.
  11. Just to double check - did you enable page numbers in the page template settings?
  12. I think I did - but will double check as got frustrated and parked it for later on lol! I think it was causing strange things like the item still showing in the repeater without affecting the on/off toggle and then re-enabling when the parent page was saved. Will give it another go and report back.
  13. Thanks all - that does all seem a bit of a headache - it's not mission critical so will probably just stick with deleting unused items rather than disabling them or just let the user manually manage them. Had naively assumed that as repeater items were pages behind the scenes that the 'toggle' would just be a proxy for unpublishing them or something similar.
  14. Yes I think you're right! Thank you!... that was driving me crazy!
  15. I think it could be because you are also using url segments. You can set the base URL for the page to be paginated when calling the pager. I can't seem to find the relevant docs at the moment but this is a snippet from a project I have open at the moment that I recall has the same issue that hopefully shows the syntax you need. $pagination = $articles->renderPager(array( 'baseUrl' => '/sector/'.$currentCat.'/' ));
  16. Unless I'm imagining it, I'm sure I've previously had the option in at least one PW installation to search/sort/filter child pages under a page's children tab. I'm working on a project that will eventually have a lot of sub-pages that the client will want to search for ease of management but I can't currently see these controls available. Am I simply imagining this functionality? Was it an extra module? Or does it only show up once there is enough sub-pages to paginate?... someone put me out of my misery!! 😂
  17. Pretty much as per the topic subject - trying to figure out how to toggle a repeater on/off using the API. Have tried setting the page status which indeed seems to hide the item but this doesn't reflect the toggle on the page editor so when you next save the page they come back on.
  18. Ok - good call on the namespacing. Can confirm the following combo of using wire404Exception() instead of PageNotFoundException() and namespacing works as follow: throw new \ProcessWire\wire404Exception(); Thanks @wbmnfktr and @BitPoet - got there in there end!
  19. Yes, you're probably right. I do usually use Master for most projects, just working on something that allows for a little more experimentation. I'll try it on another install and see if it is the dev version causing this. Thanks for your assistance (again!) @ryan - don't know if you can think of anything off the top of your head in the latest dev that might cause the issues above? If I can confirm it later in another install I log it on github.
  20. Interesting - yes am running the latest Dev version for this project as want to play with the new cookies api 😂 - shouldn't be an issue should it? Unless something has been changed/deprecated?
  21. Nope, gives the same error: Fatal Error: Uncaught Error: Class 'Wire404Exception' not found in...
  22. You're my guru today! Lol! 😂 Yes have seen this guide and have used segments loads of times. I know the script it working and breaking at the right places because if I drop the throw new PageNotFoundException(); call and just echo out a message instead it works fine. It's just the 404 call that seems to error. Doesn't seem to be able to find the class. Here's the snippet if it helps: //URL Routing for category pages and tags if($currentTemplate == 'category') { ################################################### ## Routing only required for category and tag pages ################################################### //Segment 1 == category/sector $currentCat = $sanitizer->text($input->urlSegment1); //Segment 2 == content tag e.g. marketing $currentTag = $sanitizer->text($input->urlSegment2); //Check requested category exists (in hidden categories structure) //404 if not, otherwise continue rendering page $catPage = $pages->get('/categories/')->children("name=$currentCat,include=hidden,limit=1"); $catPage = $catPage[0]; if(!$catPage->id) { throw new PageNotFoundException(); } } Probably doing something stupid.
  23. I'm using URL segments to pull some dynamic content into a page. The template uses the URL segment variable to check the content exists in another part of the site tree, if not I'm trying to throw a 404. Looking at other threads on here I think the below should do the job. throw new PageNotFoundException(); But I'm getting the following error: Fatal Error: Uncaught Error: Class 'PageNotFoundException' not found in... Is anyone able to shed any light on how I'm using this wrong? The code is currently in an include which seemed to have previously triggered some debate, but I get the same error even if I move it to the top of the parent page. I've also created a plain 404 template that doesn't include any other template elements just to rule out a code loop.
  24. Sorry for keeping you in suspense... but crazily I can confirm this works! Thanks for your help 😄
  • Create New...