Jump to content

Guy Incognito

  • Content Count

  • Joined

  • Last visited

Community Reputation

39 Excellent

About Guy Incognito

  • Rank
    Full Member

Profile Information

  • Location
    Kent, UK

Recent Profile Visitors

670 profile views
  1. Ok got it - this works! $ogImg = $page->single_image->first()->httpUrl; So as you said @gebeer it's something to do with the images being stored in an array, but no idea why looping through them manually wasn't working!
  2. Yes have tried both as a method and property.
  3. I'm not getting the memory error now, I've changed the page save to target the specific field and this seems to hugely improve performance. Pageimages being an array makes sense, but looping through the image field isn't working either. In actual fact when I start logging the output on save as I go it just seems httpUrl() isn't returning anything whereas url() does. It's because the site is running markupSEO module to handle OG and meta on all other pages. Only on this specific page type I just want to auto populate the OG image field so they can go on using the rest of the module functionality elsewhere.
  4. I've written a very basic hook script with the aim of updating one field with the value from another on page save. I want to get the full absolute URL of an image to populate an OpenGraph image tag field. If I change the url() call on single_image to httpUrl() I get a server memory exhausted error. I'm certainly not a PHP wizard but I don't think this should be particularly taxing. Have I accidentally created a loop somewhere? Calling url() works fine. Running ProcessWire 3.0.141. <?php //Hook page save to update Open Graph Image URL with featured image $wire->addHookAfter("Pages::saved(template=article)", function ($event) { //Get which page has been saved $page = $event->arguments(0); //Check featured image is set if ($page->single_image) { $ogImg = $page->single_image->url; updatePage($page,$ogImg); } else { $ogImg = 'https://examplesite.co.uk/site/templates/images/default-og-img.jpg'; updatePage($page,$ogImg); } //$message = "Open Graph image successfully generated"; //$this->message($message); }); function updatePage($page,$ogImg) { $page->seo_image = $ogImg; $page->save(); }
  5. 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.
  6. 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.
  7. 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/';?>
  8. 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?
  9. 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?
  10. Thank you - I knew I was doing something stupid... burning the midnight oil!
  11. 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); });
  12. 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.
  13. Hi @Ralf - thanks for this - completely missed Reno's note but this sounds like my exact issue and will try it out today.
  14. 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.
  • Create New...