Jump to content

Guy Incognito

Members
  • Content Count

    100
  • Joined

  • Last visited

Community Reputation

41 Excellent

About Guy Incognito

  • Rank
    Sr. Member

Profile Information

  • Location
    Kent, UK

Recent Profile Visitors

720 profile views
  1. Thank you - I can confirm I managed to log in too now, but had to go Incognito to get it to come back to life otherwise it just looped back to the login screen with no messaging. Presumably something to with session info related to my account as above.
  2. Thank you. I did try most of the different ways of including files. The problem wasn’t with the include itself which was working fine. The include itself was running some PW selectors and dynamically populating some variables critical to the rest of the page content. Seems that with a standard include things weren’t loading in the order I needed for this to work, but using an appended init file works fine 😊
  3. After some sleep I answered this myself by prepending an _init.php file in my config with the include in 😅
  4. I'm experimenting with markup regions for the first time instead of static output. Everything's going great other than I can't work out how to include other PHP files in my _main.php file that use PW functionality. Primarily I have a script that runs some checks against user permissions and runs a few PW selector queries to set up a few useful variables for a basic web app. If I include this file into my _main.php the variables don't populate as it doesn't have access to things like the PW $pages object - presumably something to do with the load order? What's the correct way to go about this, a new module seems overkill. Is it just a case of including the file at the top of every template, or is there a smarter way?
  5. Oh sorry you got me!! I was originally going to post two threads for the slightly different (but related) issues. But shortly after posting I fixed one of them and as nobody had seen or responded to it yet (or so I thought) I edited it into one post... but you must have responded at the same time. Apologies 🙂
  6. @joshua this looks like a really useful module thank you 🙂. Will definitely be giving this a try on our next project.
  7. Thanks @Robin S - although, not sure if I'm being thick here 😆, but will that change anything on the specific problem of the final image's description not being updated? The rest of my loop seems to work fine, but for some reason it doesn't apply the description to the final image/iteration. Really odd.
  8. This short script loops through some images from an XML feed and pushes new ones to an image field. It all works perfectly, except for some reason the last image (only) in the loop each time doesn't receive the image description... can everyone spot why? TIA! 🙂 foreach ($propertyImages as $img) { $fileName = trim($img[0]); if ( !empty($fileName) ) { $imgPath = '../property_data/'.$fileName; if(file_exists($imgPath) && !in_array(strtolower($fileName),$currentImages)) { $p->property_images->add($imgPath); $p->save(); $newImg = $p->property_images->last(); $newImg->description = $img[1]; $p->save(); } } }
  9. 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!
  10. Yes have tried both as a method and property.
  11. 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.
  12. 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(); }
  13. 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.
  14. 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.
×
×
  • Create New...