Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by Rob(AU)

  1. @horst when you said you would write a tutorial I did not expect a short reference manual! Thank you heaps. @wbmnfktr, yes, I eventually found my way here - life delayed my return.

    This looks awesome and I'm looking forward to using it. At the moment it reveals that I am a better photographer than coder...
    I have encountered an error at the beginning of step 4. I have tried to tweak the code to reflect my fields and setup, but keep getting an error. I'm testing on my NAS and my setup uses MediaManager and has photo as the photo/image field. Thus I have the following:


    <?php namespace ProcessWire;
    include __DIR__ . '/index.php';

    function ourWatermarkTestfunction(Pageimage $originalImage) {
        $watermarkedImage = $originalImage;
        return $watermarkedImage;

    $image = $pages->get('/photos/cloudscapes/yalata/')->photo->media;
    $variation = ourWatermarkTestfunction($image);
    $variation = $variation->width(800);
    echo "<img src='{$variation->url}' alt='{$variation->description}' />";

    The following error is thrown:



    Argument 1 passed to ProcessWire\ourWatermarkTestfunction() must be an instance of ProcessWire\Pageimage, null given, called in /volume4/web/landscapes/test.php on line 10

    In my current template, using MediaManager, the following produces the expected output:


    foreach($page->photo as $photo) {
      $image = $photo->media->url;
    $out = "";
            $out .=  "<img src=$image class='mainimageH' alt='$headline'>";
            echo $out;

    What am I'm missing or doing wrong?

    • Like 1
  2. @kongondo now that I have had time to explore a bit more it is making more sense - I had a few family things that interrupted ... male, multi-tasking ... epic fail

    I am using PW 3.0.165 and ran into the images not appearing to upload issue, but only on the live site, but that is not causing an issue now.

    Is it possible to do something similar to the following using the image media?
    echo "<img srcset='{$page->image->srcset('2500x0,/2,/3,/4')}' class='mainimageH' alt='$page->headline'>";

    I found a way while writing this. It maybe not elegant, but I'm sharing as it may be helpful in the future.


    foreach($page->photo as $photo) {
      $imgsrcset = $photo->media->srcset('2500x0,/2,/3,/4');
         $out = "";
         $out .=  "<img srcset='$imgsrcset' class='mainimageH' alt='$page->headline'>";
         echo $out;

     From reading the documentation there are hints about image variations. Is this something designed to provide different images sizes for varying viewport dimensions?


  3. Having a problem displaying images on the front end.

    I've just purchased MediaManager and have successfully imported a heap of images. Now I am trying to include a MM image and display it via an existing template.

    The steps I have followed thus far:
    1. Add a new textarea field to the existing template - named PortfolioImage
    2. Edit a page and insert a single image into the PortfolioImage field, by selecting a MM image. The image shows up in the edit page.
    3. In the template file I added the following line:
                 if($page->PortfolioImage) echo "<img src='{$page->PortfolioImage}' class='mainimageH' alt='$page->headline'>";
    4. The output I get for that line is: <img src='&lt;p&gt;&lt;img alt=&quot;&quot; class=&quot;hidpi&quot; src=&quot;/landscapes/site/assets/files/1500/ql033n.jpg&quot; width=&quot;1200&quot; /&gt;&lt;/p&gt;' class='mainimageH' alt='some text'>

    If I have <img src='{$page->PortfolioImage->url}' instead Tracey Debugger shows this error message:  

    PHP Notice: Trying to get property 'url' of non-object in .../web/landscapes/site/templates/photos.php:10

    I am clearly doing something wrong. Can anyone point me in the right direction please?

    PW 3.0.165, MM 0.1.2, PHP: 7.3.16

  4. I am trying to import the database from my live website to my local server.

    It seems that exporting the website database to a sql file using Ryan's module only copies some cache tables.
    When on the DB Backups view page the sql file that was exported from the live site, and uploaded to the local server, shows as having 100 tables and 3,00 rows. Yet when I try to restore it the following error shows up:


    ProcessDatabaseBackups: Error restoring: /volume4/web/landscapes/site/assets/backups/database/2021_06_05_live.sql

    I have exported the database using phpmyadmin, then imported it to the local server using phpmyadmin. That appears to be working, except that I then cannot edit or add pages. The following error come up:


    PagesEditor: Error saving field "Title" — Unable to save to 'field_title' for page that doesn't exist in pages table

    ProcessPageAdd: Unable to save to 'field_title' for page that doesn't exist in pages table

    Both installations are using ProcessWire 3.0.165, the live server is running PHP version: 7.3.28, and the local server PHP version: 7.3.16. Both use the same (long) password.

    If anyone can give me some help that would be greatly  appreciated!

  5. Here is my website, built with ProcessWire, and still being refined as I learn more.


    My website journey has taken me via plain html, Singapore (anyone remember that?), Wordpress, modx, and now finally PW. Along the way I experimented with drupal, concrete, silverstripe and a few others that I'd rather forget. All self-taught and done between full-time work, family and a passion for photography.

    I have found using ProcessWire relatively simple - despite the steep learning curve of having to learn about php... The community support is fantastic.

    • Like 16
  6. Thanks again Bill,

    Yes, debugging is turned on, and I'm using Tracy Debugger - neither shows any errors.

    The live site uses PHP 7.3.27, and the local/NAS is 7.3.16, so I figure they are pretty close. The live site uses MySQL, and the local is using MariaDB 5, but that hasn't been an issue before.

    I have been experimenting, and can edit and save changes to the fields via Adminer, but edits via the usual page editor still do not save to the database.
    Editing a page via Adminer is fraught with danger though...

  7. Thanks Bill,
    I looked in the logs and found nothing that I think is relevant. The two screenshots show the last error. However, replicating the issue of unsaved edits does not add further entries to the logs.

    Could there be an issue with the local db having different usernames to the live db - even though my local username for the db has all privileges according to phpmysql?
    I'm clutching at straws here.





  8. Hi,

    I am running ProcessWire 3.0.165 on my Synology NAS, along with another couple of test sites. The other sites are working fine.

    The site will allow me to edit pages, and shows that the edits have been saved (as per the screenshot), but on reloading shows no change. 
    I can however edit templates and fields.

    The database was imported from my live website (where editing works), and changes of db user etc. made in the site\config.php file.

    Any help would be appreciated as I have searched the forum for an answer.



  9. This is what I really appreciate about the PW community! I post a question, have dinner and come back to a helpful answer!

    Thank you teppo. Your explanation helped me learn more about PW. 

    I'm closer, but not quite there. I'm obviously missing something about how to use the module.
    Using teppo's code:

    if($page->main_image) echo "<img data-srcset='{$page->main_image->srcset('1500x1000,/2,/3,*1.5')}' class='mainimageH' data-sizes='auto' alt='$page->headline'>";

    produces this output, but no image.

    <img data-srcset='/landscapes/site/assets/files/1216/pnz007n.1500x1000.jpg 1500w,/landscapes/site/assets/files/1216/pnz007n.750x500.jpg 750w,/landscapes/site/assets/files/1216/pnz007n.500x333.jpg 500w,/landscapes/site/assets/files/1216/pnz007n.2250x1500.jpg 2250w' class='mainimageH' data-sizes='auto' alt='sunset at Lake Tekapo on the South Island of New Zealand'>

    I came back to it this morning, and was able to work around this by using srcset instead of data-srcset. The code that works is:

    if($page->main_image) echo "<img srcset='{$page->main_image->srcset('0x1000,/2,/3,*1.5')}' class='mainimageH' alt='$page->headline'>";


  10. I've just discovered this module and am unable to get any images to show from it. My setup is on localhost using php 7.3, PW 3.0.165 with lazysizes.

    The code in my template is:

    if($page->main_image) echo "<img data-srcset='$page->main_image->srcset('1500x1000,/2,/3,*1.5')' class='mainimageH' data-sizes='auto' alt='$page->headline'>";

    No image is shown and the output I get is:
    <img data-srcset='pnz007n.jpg->srcset('1500x1000,/2,/3,*1.5')' class='mainimageH' data-sizes='auto' alt='sunset at Lake Tekapo on the South Island of New Zealand'>

    My guess is it is something simple that I'm missing ?

    I too would really like to see this support WebP.

  11. I am having issues with my site being very slow, for both the front and back end. Having researched and looked at previous posts on the topic has not helped, but the threads I could find were from a while ago.

    The error I'm getting in the Exceptions Log is: 
         SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
          In /wire/core/WireDatabasePDO.php line 499

    Tech support for my hosting investigated and could not see any MySQL issues. At the same time, the dev copy of the site on my localhost is also going slow.

    Another site on my localhost is working as normal, so that seems to eliminate the hosting as a problem.

    I am hoping someone can shed some light on what might be causing this.


  12. Hi,
    I am learning PHP while in the process of building a recipe website and enjoying the challenge.

    One dilemma has stumped me. I have an Ingredients List page, which is parent to a series of ingredient pages. The ingredient pages has two fields, Title and ingredientType (for spices, dry, wet, vegetables etc). Thus there is one list of Ingredients available to be included in recipes. 

    On the Recipe template there is an Ingredients Repeater field that includes fields for quantity and extra details (like room temperature for butter for example) as well as the ingredient field. If I include the ingredientType field in the repeater it shows as a blank field rather than showing the data saved from the ingredient page. It looks a little like this:

    Ingredients List page
               ingredient page - title field
                                          - ingredientType  field

    Recipe page
              title field
              description  field
               Ingredients repeater field
                        quantity field
                        ingredient field
                        ingredient details field

    What I want to do is be able to include the ingredientType field in the array that the Recipes template uses to output the Recipe page. I will then use the ingredientType to sort the Ingredients Repeater data for output.

    Conceptually this could either be at the adding a new recipe stage, or by somehow adding the ingredientType data to the array used for page output. 

    I just can't work out how to do it. Any clues would be greatly appreciated.

  13. I have found a solution and thought I would share it for the benefit of others. It may not be the most efficient or elegant solution but it is working.

    After some trial and error the solutions suggested in topic 7659, especially by formulate, began to make sense.

    In the tagging.php template file is the following code:

    $fullList = $pages->find("$searchTxt=$thisTag");           // this select all pages where page field "Tags" contains a page with title of our tag
    $tagList = $pages->find("$searchTxt=$thisTag, limit=10");  // this selects the same as above but limits the rsults for pagination
    $session->taggedPages=(string)$fullList;                   // save the result of the first search for use in the portfolio template

    In the portfiolio.php template file the following gets the prev / next pages from the tag search:

         $fullList=$pages->find("id=" .$session->taggedPages);
         $next = $page->next($fullList);
         $prev = $page->prev($fullList);

    This means that going to the prev / next page is not limited to those paginated on the tagging page.

    I hope that makes sense and helps someone else.

    • Like 2
  14. Thank you horst, that solved an issue I was yet to solve. dragan, your clue was too cryptic for my limited knowledge.

    PW is certainly easy to work with if you are prepared invest some thought.

    My issue is not solved, but that's because I didn't describe it clearly enough.

    The page with the thumbnails (now paginated!) lists all the images with the selected tag. It is based on my tagging template. Clicking a thumbnail opens a page based on my portfolio template for the individual image, each of which has it's own page.

    What I would like to do is have the prev/next links on the individual, portfolio template styled page move through the images that were on the tagging page. This will change depending on the selected tag, and will be different to where the images sit within the content tree.

    How would this work in PW? I have a sense that it involves sessions ... but have not been able to work it out.

  15. I am building a portfolio site based on PW 3.0.124 and learning php as I go. The site uses various tags on the pages for each image. The tagging is sorted and clicking a tag link brings up a page of links to images with the same tag using the following code:

    $searchTxt = $page->searchTag;
    $thisTag = $page->name; // Current clicked tag
    $tagList = $pages->find("$searchTxt=$thisTag");  // select all pages where page field "Tags" contains a page with title of our tag

    I have a Prev / Next section on the image pages, but it relates to the tree location, rather than the tagList page. 

    My guess is that the $tagList array needs to somehow be saved to be used to iterate through it, possibly using sessions ... but I can't figure out how to do that.

    Any help/pointers would be appreciated.

  16. Thanks wbmnfktr,
    you put me on the right track. I had WireMail: SMTP installed but not configured. I actually uninstalled the module and emails are now being sent. 

    I am having an issue where an email is sent to my address, but not to the person using the Contact form. 

    The following is in the contact page template:

    <?php $scf = $modules->get('SimpleContactForm');
    $options = array(
    'btnClass' => 'butn1',
    'btnText' => 'Send',
    'emailMessage' => 'You have successfully sent a message to Rob',
    'item_label' => "",
    'classes' => array(
    'item' => 'input-field'
    echo $scf->render($options); ?>
    <br ><br ><br ></div> </div>
    <?php include('./includes/foot.inc'); ?>

     Any clues would be appreciated.

  17. I have installed the module and the page appears as expected. The submit button works and redirects to the success page, or not if it detects spam.

    No emails are sent and I get the following errors in the log:

    [ERROR] Mail has not been sent to Name 

    [ERROR] Additional mail could not be sent to Name

    running PW 3.0.123 on PHP 7.1.31

    I have searched the forum for a solution. Can anyone suggest where else I might look to solve this?

  • Create New...