Jump to content

rushy

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by rushy

  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...
  16. I tried the above to no avail. I'm really stumped now. Just can't get repeaters to work properly on this server but they are fine on another server. I can't see what the difference is...no errors or warnings. What a pain.
  17. I'm thinking this must be a PHP config. problem on the server. I found a problem with ini_set being disabled for security reasons and thought that would be the problem but now it's enabled the problem persists. See other post: override php.ini It's a long shot, but I think I will reinstall PW from scratch now that I have no server errors - just in case the installation had been affected by the PHP error. I wonder if there is a definitive statement of PHP functions that are required for correct operation of PW? That would help me track down the problem as I have no error messages anywhere now as far as I can see, but images in repeaters still don't work properly on this server. Paul
  18. No, I only have 2 'instances' of the repeater on my page, with 2 fields in the repeater 1 image and 1 TextareaLanguage. The image description field comes with the image.
  19. My problem seems specific to the description text fields provided with images. When used within repeaters, the description field is not saved and original text reappears after save. How can i enable extra logging to track down this problem? I have debug = true in config.php and no messages are seen. Any ideas of where to look? Thanks - Paul
  20. Thanks dragan. I have contacted the host support and they have changed the PHP config. to allow ini_set. The error in the error_log has now gone.
  21. Has anyone come across a shared server where the PHP function ini_set is disabled for security reasons? It seems to break PW correct operation and generate a large error_log. I keep getting guided toward adding lines into the vhost .htaccess but what exactly I should add is unclear. (I tried "php_flag php_admin_value on" and "php_flag php_admin_flag on" to no effect.) As far as I can see I do not have permission to change the php.ini. Anyway if anyone has solved this problem for PW sites on shared server I would be grateful of some help! More info for those that have time to read all about my investigations - I ran into the problem when I copied a site over to a clients shared server. The problem doesn't occur on my localhost or my own shared server, so I know it must be a config. problem on the clients host. The problem seems specific to text fields associated with images within repeaters. I have a repeater defined containing an image and if I change text in the description field and hit save - the text is not saved and original text reappears. This works fine on my local host and my shared host so I guess it something particular to the PHP config on my clients host. I have noticed on the client server there is an error_log in the public_html folder. It contained hundreds of the same error message - namely - [01-Nov-2018 13:49:42 Europe/Berlin] PHP Warning: ini_set() has been disabled for security reasons in /home/rushy/public_html/wire/core/ProcessWire.php on line 190 I don't see this error on the other servers, so guessing this is may an indication of the problem, I decided to try and find out how to re-enable ini_set on a shared server. There is quite a lot out there about this, but I've not found out a way so far. Thanks - Paul
  22. Thanks for the replies. I gave up on the profile export and did it all manually with a db dump as per bernhard suggested and it works fine. Robin S: I note the quote above and I had not fully taken that on board - I think my problems could have been due to not recreating the site user accounts and failure to setup the config.php correctly on the new server. Thanks to you both for helpful suggestions. Paul
  23. I'm trying to migrate a PW site on my local dev server to a shared hosted server and have used the ProcessExportProfile module to export a profile as a zip file. So far so good. I then deploy new install of PW on the server by unzipping the PW installation files but I do not run the install until I have replaced the various site profiles with the files from the exported profile. So basically: In the PW install files I delete all the site-* folders except site-default. This one I overwrite with the export profile folders so it contains my assets, install, modules and templates folders together with the exported config.php I then run the install in the browser in the normal way and it starts the installation and I can see my website profile in the list and I select it. It proceeds as normal and gets to setting up the database. I provide the db info. as usual and it proceeds as far the info. below and 'hangs' at this point , it never goes on to setup the PW login admin. and complete the install I am left at that screen. If I relaunch the browser at the site it all seems to work! BUT I have no admin login to PW so cannot get into the backend. I have basically followed the Installation, Moving and Troubleshooting guide by Joss Sanglier: http://processwire.com/docs/tutorials/installation-moving-and-troubleshooting/page4 Any idea where I could check for an error log or some help as I am at a loss as to the problem. Many thanks. Paul ProcessWire 3.x Installer Test Database and Save Configuration Database connection successful to pinpoin1_master Saved configuration to ./site/config.php Profile Import Imported database file: ./wire/core/install.sql Imported database file: ./site/install/install.sql
  24. Thanks for the heads up. Did you fix the problem? Hosting is provided by the client on a shared server so nothing special there and I don't have access to change anything like mod_security. I am getting an error_log file on the server filling up with "PHP Warning: ini_set() has been disabled for security reasons in /mypath/to/public_html/wire/core/ProcessWire.php on line 190". I don't get this on my localhost. The line at 190 is: ini_set('display_errors', true); so I think this is just to do with error reporting and probably not related to the problem, but I really don't know.
  25. Hi My first use of repeaters. They seem very useful, but I'm having a strange problem with the descriptions of the images field. I can't change them after deploying from my local dev server to the live server. I have defined a repeater with one images field and one textarea (multi language) field. This works as expected when added to a template and on the page I add an image and text in 3 languages. I usually populate the image description fields with a caption text in 3 languages so that I can output a caption if required under the image. Now this all works a treat on my test localhost server, but when deployed to the live site the captions cannot be changed on these repeater image fields. If I login to the live site and change the image text in there - as soon as I hit save the text goes back to what it was before! I am logged in as superuser so can't work out what the problem is. I had a search through the forums but couldn't find a similar problem. Any ideas where to look for some clues to what the problem may be? I'm using ProcessWire 3.0.96 Many thanks - Paul
×
×
  • Create New...