Jump to content

rushy

Members
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

9 Neutral

About rushy

  • Rank
    Jr. Member

Profile Information

  • Gender
    Male
  • Location
    Bournemouth & Málaga
  • Interests
    Motorcycles, music, meteorology, vintage radio restoration, computer chess programming, tech. in general

Recent Profile Visitors

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

  1. SOLVED. As usual with processwire it's very easy. I just needed to do use add() function to add a copy to the album and then delete the relocated image. In the code below $instr contains the album name for destination album. case 'move': // Move image(s) from one album to another $out = "<p>Move $nosel images(s) to album $instr</p>"; $newalb = $pages->get("/{$instr}/"); $newalb->of(false); foreach($selected as $item){ $album = $pages->get($item->album); $album->of(false); $image = $album->images->getFile($item->file); $basename = $image->basename; $filename = $image->filename(); $out .= "<p>{$basename} in {$album->title}</p>"; $newalb->images->add($filename); // delete the relocated image $album->images->delete($image); } $newalb->save('images'); $newalb->of(true); $out .= saveUpdatedAlbums($pages, $selected); $out .= "<p>Updated album $newalb->title</p>"; $response['message'] = $out; break;
  2. Hi all Continuing my first project where I am creating and manipulating stuff from the frontend. Till now I've always added things like images from the backend, but in this project I need to add and move images from a frontend control. This is a photo album where images are stored in albums, each album being a page containing a Pageimages array in the usual way. So what I want to know is how do I move an image from one album (page) to another in the frontend? I just need some guidance on how to approach this. I suppose I need to do a copy and delete - but how do I copy an image or images from one page to another? What function should I use to create a new image on an existing page? I include a code snippet from the server side of my delete image request and it works fine. I'd like to implement something similar for a move and upload new image request. Many thanks for any help. Paul <?php namespace ProcessWire; // sanitize inputs as 1-line text $action = $sanitizer->text($input->post('action')); $instr = $sanitizer->text($input->post('input')); $sel = $input->post('selected'); // Expect JSON for image selected image list $selected = json_decode($sel); $nosel = count($selected); $response = array(); // for building JSON response switch($action) { // delete selected images case 'delete': $out = "<p>Deleted $nosel image(s)</p>"; foreach($selected as $item){ $album = $pages->get($item->album); $album->of(false); $out .= "<p>Image {$item->file} from album {$album->title}</p>"; $album->images->delete($item->file); $album->of(true); } $out .= saveUpdatedAlbums($pages, $selected); // add the response message for the delete $response['message'] = $out; break; ...... // save any album that had an image deleted function saveUpdatedAlbums($pages, $selected) { $cur = ''; $out = ''; foreach($selected as $item){ $album = $pages->get($item->album); if($album->id != $cur) { $album->of(false); $album->save('images'); $album->of(true); $cur = $album->id; $out .= "<p>Updated album {$pages->get($cur)->title}</p>"; } } return $out; }
  3. I confirm that this works - when I called trackChange before save the change to the image description field was savedA. Thanks again Horst. As a footnote, when updating tags I found that I can use $image->addTag('foo,bar,baz') without trackChange and tags were saved because it's a dedicated function to add tags. Regards
  4. Thanks Horst. My file basename is correct as I am able to echo out all the properties of the image, but I did not know about trackChange perhaps that is the missing bit. $pgfile = $al->images->getFile($file); if($pgfile) { echo "basename => $pgfile->basename \n"; echo "description => $pgfile->description \n"; echo "ext => $pgfile->ext \n"; echo "filename => $pgfile->filename \n"; echo "filesize => $pgfile->filesize \n"; echo "filesizeStr => $pgfile->filesizeStr \n"; } The above echoes out all the properties as expected , but assigning description to something does not update it when I save page. I guess I'm only changing a local copy here and it's not "connected" to the page. I imagine the trackChange makes that happen. I will try it and report back. Many thanks
  5. Bit of a newbie type question, even though I've been using PW for quite a while, I've not had to manipulate assets from the front end before. I now have a need to update image properties from the front end and I'm trying to update an image description and tags when clicking on a link. I get the selected image and for example I can delete it with the code below. But I am missing some basic understanding when updating image description field as nothing happens, no errors but the description field remains empty. Any idea what steps I am missing? Many thanks. // how to update image description? $al = $pages->get($album); $pgfile = $al->images->getFile($file); $al->of(false); $pgfile->description = "Test description"; $al->save(); // to delete an image - this works $al->of(false); $al->images->delete($file); $al->save();
  6. Thank you. That works! But I now realise I need to iterate each album to build a list of tagged images matching. I wonder if there is a sub selector that can do that? Thanks again I can get on with it now 🙂
  7. Hi I have a number of pages with images and I'm having a problem selecting on the image descriptions. In the code snippet below, the I added images.description field to my selector and it does work in that I get the expected no. of matches. So findTag gets me a list of images matching the tags in the code, but if I swap that line for the commented line $match->images->find it does not work giving 0 results. There is findTag for tags but for description there is not a dedicated function, so I should use find. But what selector will give me a list of images matched by image description? Many thanks. if($q !== '') { $keywords = $sanitizer->selectorValue($q); $matches = $pages->find("template=album, title|summary|images.tags|images.description~=$keywords"); echo "<p>match count: $matches->count</p>"; foreach($matches as $match){ echo "<p>{$match->title}</p>"; $i = $match->images->findTag($keywords); //$i = $match->images->find("template=album, images.description~=$keywords"); GIVES ZERO MATCHES $j = count($i); echo "<p>No. of image matching: $j</p>"; foreach($i as $img){ echo "<img src='{$img->url}' alt='{$img->description}'>"; } } }
  8. Thanks Horst. I created a test file with echo phpinfo() and found in the core table output the following listed as disabled: disable_functions shell_exec ,exec, system, popen, set_time_limit this for both local and master value columns in the table. i note your comments about switching or upgrading host! Paul
  9. I had no luck with any of the above, in the _init or config.php it gave an error as it's disabled by the host and in .htaccess the site did not run it just displayed a config error. Fasthosts have replied to my question saying there is no option to use set _time_limit on shared hosting. (see below) As a workaround I have commented out the set_time_limit call in the core and it works ok - for now...
  10. Hi. I've been using Processwire for a few years now and installed it on a few different shared hosting servers without issues, but I'm now running into an issue on a Fasthosts shared server that I've not seen before. The installation goes ok and I have a working default site profile but I am unable to complete any uploads of images. It just hangs at the progress spinner during the upload. I thought it might be a priviledge issue so have temporarily set the dir / file privs. as 777 / 666 just to test that but it made no difference. I have no errors in the wire log. In server error log I have: set_time_limit() has been disabled for security reasons in ....htdocs/wire/core/ImageSizerEngine.php on line 1035 and i note in the assets/file dir. where the image is being stored the date on the file being created has a year of 1970 and 0 length. If I leave the page this file disappears and nothing has been stored. Does anyone know how I can enable set_time_limit if this is likely to be the problem? Many thanks! Paul
  11. So far I found that using if(!$config->ajax): in my _main.php around head and foot parts and having a div targetted by Javascript as is commonly used - but in the case of an Ajax call I use wireRenderFile() to load markup from a file containing just the markup I need seems to work.... but I'm still playing with this. Paul
  12. Hello. I have recently adopted PW markup regions and really like this way of working. However, I am also trying to learn how to use Ajax and I am not sure of a good way to use the two together. Has anyone got any experience, tips or hints on using them together? For ajax - I've used a simple scheme where I have a "webservice" template and page that handles Ajax requests and returns the appropriate content wrapped with some markup for the requesting page. I have markup regions enabled and all my pages (bar webservice) include a _main.php which brings in the headers, a default body and the footer. My javascript intercepts the page links and does my ajax call to webservice and that sends back the appropriate markup which is then placed by in the div #body defined in _main.php. Does this seem a reasonable way to work? I guess I am looking for some advice before I invest too much time going the wrong way! Any guidance, remarks, comments, or a nudge in the right direction greatly appreciated. Paul
  13. Thanks for the suggestion. I couldn't see any errors in the Chrome developer network tab, but I did try adding the mod_security.c section as given in your other post. Unfortunately it didn't make any difference - the problem persists. I've installed Tracy debugger just in case it can throw any light on this problem. Now I have to learn how to use it properly! Rushy
  14. I'm using 3.0.98. I don't think it can be a PW problem though. I'm thinking perhaps server config? The fact is I've run the same build on a different server and the problem doesn't occur. Also it's fine on my local dev server. There are no errors seen to give me a clue (or I don't know where to look for config. errors)
  15. Good idea Robin, I will certainly try Tracy Debugger to see if it reports any problem in the backend. My $config is already set true and no visible errors are reported and everything else seems to work fine. Fingers crossed I can find something as I'm fresh out of ideas now...
×
×
  • Create New...