Jump to content

biber

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by biber

  1. Hi @poljpocket, sort (-iname ... ) does not work, because iname_* contain different criteria to sort the images. To have an impression of the site, here's the link: (The new sorting function is not yet implemented completely) http://www.malabu.de But ->reverse(); was the right way, it works! Thanks to you all Günter
  2. hi @ShaunaB1 and @Gideon So, Thanks for your efforts to help to my problem. Unfortunately a simple "-" does not solve my challenge. I also tried a "sort(1/iname_3)", where iname_3 contains a timestamp - no success. @Gideon SoI did a dump on $images in line 32 and it throws a long list of all parts of the image-field. Sorting itself works as desired, but not with an option "image_created descending". Greetings Günter
  3. Hi, I have built a site with some galleries, which can be ordered by different criteria, like place, name or date_created. This works fine, iname_1,2 or 3 can be chosen by user. Now I want to have the option to sort the images "latest image first". Setting "rsort" instead of "sort" in line 31 comes up with this error: Where is my mistake? Any idea? Here is my template: 1 <?php include(\ProcessWire\wire('files')->compile(\ProcessWire\wire("config")->paths-> root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=> true,'skipIfNamespace'=>true))); // include header markup ?> 2 3 <div id='haupt'> 4 5 <?php 6 7 // output 'headline' if available, otherwise 'title' 8 echo '<h1>' . $page->get('headline|title') . '</h1>'; 9 10 //get all segments and clean segments! 11 $seg1 = $sanitizer->pageName($input->urlSegment1); 12 $seg2 = $sanitizer->pageName($input->urlSegment2); 13 $seg3 = $sanitizer->pageName($input->urlSegment3); 14 15 //check for the second urlsegment not needed 16 if ($seg2) { 17 // unknown URL segment, send a 404 18 throw new \ProcessWire\Wire404Exception(); 19 } 20 21 //check for the third urlsegment not needed 22 if ($seg3) { 23 // unknown URL segment, send a 404 24 throw new \ProcessWire\Wire404Exception(); 25 } 26 // Sortierung übernehmen: 27 $order = $input->get->order; 28 29 // sortiere nach name_: 30 if ($order >0) { 31 $images = $page->images->sort("iname_".$order, SORT_NATURAL | SORT_FLAG_CASE); 32 $session->set($order, $order); 33 } 34 35 // ohne Sortierung: 36 else { 37 $images = $page->images; 38 } 39 40 //normal content without first url segment! 41 if (!$seg1) { 42 43 echo $page->body; 44 if (!empty ($page->name_1|$page->name_2|$page->name_3)) echo '<p>Sortierung nach '; 45 if (!empty($page->name_1)) 46 echo '<a class="tab" href="'.$page->url.'?order=1">'. $page->get('name_1'). '</a>&nbsp;'; 47 if (!empty($page->name_2)) 48 echo '<a class="tab " href="'.$page->url.'?order=2">'. $page->get('name_2'). '</a>&nbsp;'; 49 if (!empty($page->name_3)) 50 echo '<a class="tab " href="'.$page->url.'?order=3">'. $page->get('name_3'). '</a></p>'; 51 52 // output images 53 foreach($images as $image) { 54 $iname_3 = $image->created; 55 $thumbnail = $image->height(100); 56 echo '<div class="rahmen"><a href="'.$page->url . $image.'?order='.$session-> get($order).'"><img class="shadow" src="'.$thumbnail->url.'" alt="'.$image-> kopf.'" title="'.$image->kopf.'" loading="lazy"></a></div>'; 57 } 58 59 } 60 61 //special view output with an url segment... 62 if ($seg1) { 63 // get the image in the correspondent position: 64 $index = $input->$seg1; 65 $image = $page->images->index($index); 66 67 // Link zum vorigen Bild: 68 echo '<a href="'.$images->getPrev($images->$seg1).'?order='.$session->get($order). '"><img src="'.$config->urls->site.'templates/styles/links.gif" alt="voriges Bild" title="voriges Bild"></a>&nbsp;'; 69 70 // Link zur Thumbnail-Seite: 71 echo '<a href="'.$page->url.'?order='.$session->get($order).'"><img src="'.$config ->urls->site.'templates/styles/index.gif" alt="zurück zur Übersicht" title="zurück zur Übersicht"></a>&nbsp;'; 72 73 // Link zum nächsten Bild: 74 echo '<a href="'.$images->getNext($images->$seg1).'?order='.$session->get($order). '"><img src="'.$config->urls->site.'templates/styles/rechts.gif" alt="nächstes Bild" title="nächstes Bild"></a><br />'; 75 76 // Bild zeigen: 77 echo '<img class="shadow" src="'.$images->url . $seg1.'" alt="'.$images->$seg1-> get('kopf|name_1').'" title="'.$images->$seg1->get('kopf|name_1').'">'; 78 79 //echo '<img class="shadow" src="'.$images->url. $seg1.'" alt="'.$images->$seg1->kopf.'" title="'.$images->$seg1->get('name_1|kopf').'">'; 80 81 82 // Textfelder zu den Bildern anzeigen: 83 echo '<h2>'.$images->$seg1->caption.'</h2>'; 84 echo '<h2>'.$images->$seg1->get('kopf|name_1').'</h2>'; 85 //var_dump($images->$seg1->filedata['_109']); 86 //var_dump($images->$seg1->caption); 87 echo '<p>'.$images->$seg1->bildtext.'</p>'; 88 echo '<p>| '.$images->$seg1->iname_1.'&nbsp; &nbsp;| '.$images->$seg1->iname_2. '&nbsp; &nbsp; | '.date("d.m.Y",($images->$seg1->created)).' |</p>'; 89 } 90 ?> 91 </div><!-- end content --> 92 <?php include(\ProcessWire\wire('files')->compile(\ProcessWire\wire("config")->paths-> root . 'site/templates/_foot.php',array('includes'=>true,'namespace'=>true,'modules'=> true,'skipIfNamespace'=>true))); // include footer markup ?>
  4. If I set a var_dump($images->$seg1->filedata['_109']); I get the error
  5. Hi all, still have problems with that userdefined fields: to every image I have defined some fields, represented by a number in the database-field "filedata". Here one example: {"_109":{"data":"ehemalige Post","data1015":""},"_108":"schon lange gibt es hier kein Postamt mehr","_110":"S\u00f6rup Dorf","_111":"","_112":"2024-02-17 00:00:00","_114":""} _109="kopf", _108="bildtext", _110="iname_1", _ 111="iname_2" and _112="iname_3" I can access to this content by $images->$seg1->filedata['_xxx'] for all parts but not to _109(kopf), which is a TextLanguage-field and contains two parts. While I do not need the language-function anymore, I tried to convert it to a simple Text-field, but this lead to a long error-list and no success. Any idea?
  6. My url segments are the names of the images. This works as desired. You may have a look at the site: http://malabu.de It is an elder version, I'm working at a new edition with a better sorting function.
  7. Hi @ngrmm, with $seg1 I am able to access a single image of my gallery. The method is described here: https://processwire.com/docs/front-end/how-to-use-url-segments/ The crazy thing about my template is, that it works with $images->$seg1->get('kopf|name_1') but not with get('kopf') or $images->$seg1->kopf
  8. hi @ngrmm, thanks for your reply. maybe I have shortened my code-excerpt too much 😉 $seg1 = $sanitizer->pageName($input->urlSegment1); $images = $page->images; name_1 defines a sort criteria, not importent in this context. My problem is: At the overview with all thumbnails I can access to my user-defined imagefields (for exemple field "kopf"). But if I select one image I only get an empty string. $images->$seg1->get('kopf|name_1') shows field 'kopf' as expected. $images->$seg1->get('kopf') shows an empty string
  9. Hi, in a gallery I have defined some extra fields to my image-field. As long as I show the overview with all thumbnails I can access to my fields (for exemple field "kopf"). But if I select one image I only get an empty string. Very strange: if I get ('kopf|name_1') it shows the content of the "kopf"-field. ("name_1" is a field at the page without reference to the image) Here an excerpt from my template:
  10. Hi @elabx, thanks for your reply. Maybe, I did not yet understand the technique of "new image fields", and so it was not very helpful to mess around with the database. I will try to purge the relics of the old system from my templates and be happy. Thanks for your help, @elabx, also to @ngrmm, who's hint showed the key page.
  11. Thanks @ngrmm, I have read the announcement about the new custom field option. My problem is: I have a site with about 1500 images with more or less text in ImageExtraFields. This is stored all together in one field 'filedata' as shown in my first post. Now I want to separate this content and put it into fields 'caption', 'description', 'textarea', which are existing in the database, but empty. Here a screenshot of the database structure:
  12. Hi, I have built a simple website based on image-galleries some years ago. (malabu.de) To add descriptions I used the ImageExtraModule by just3be. In the database I can see, that some of the data are collected in the field 'filedata' in the table field_images, while the fields 'caption', 'description', 'textarea' stay empty. It looks like {"_109":{"data":"ehemalige Post","data1015":""},"_108":"schon lange gibt es hier kein Postamt mehr","_110":"S\u00f6rup","_111":"einhundertelf","_112":"2024-02-17 00:00:00"} very confusing. I would prefer to get the content seperated into the standard fields like 'caption', 'description', 'textarea'
  13. Thanks to @netcarver and @da² @da²: Including namespace solved my problem. Additional I had to learn to put this to the first line and to close it by ?>
  14. Hi, I copied my website malabu.de on a local LAMP-server which runs PHP 8.2.7 and got the following Fatal Error: As I am not very familiar with PHP I do not know, how to fix it. This is my _head.php-file: <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo $page->title; ?></title> <meta name="description" content="<?php echo $page->summary; ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/malabu.css" /> </head> <body> <!-- navigation --> <div id="menu"> <h1 class="titel"><a href="/">malabu.de</a></h1> <nav id="nav"> <ul> <?php // top navigation consists of homepage and its visible children $homepage = $pages->get('/'); $children = $homepage->children(); // make 'home' the first item in the navigation $children->prepend($homepage); /** * Recursive traverse and visit every child in a sub-tree of Pages. * * @param Page $parent root Page from which to traverse * @param callable $enter function to call upon visiting a child Page * @param callable|null $exit function to call after visiting a child Page (and all of it's children) */ function visit(Page $parent, $enter, $exit=null) { foreach ($parent->children() as $child) { call_user_func($enter, $child); if ($child->numChildren > 0) { visit($child, $enter, $exit); } if ($exit) { call_user_func($exit, $child); } } } visit( $pages->get('/') , function(Page $page) { echo '<li><a class="men" href="' . $page->url . '">' . $page->title . '</a>'; if ($page->numChildren > 0) { echo '<ul>'; } } , function(Page $page) { echo '</li>'; if ($page->numChildren > 0) { echo '</ul>'; } } ); // output an "Edit" link if this page happens to be editable by the current user if($page->editable()) { echo '<li><a class="men" href="'.$page->editURL.'">Edit</a></li>'; } ?> <!-- öffne Mailformular --> <li><a class="men" href="mailto:info@malabu.de"><img src="<?php echo $config->urls->templates?>styles/brief.gif" width="25" height="15" alt="info@malabu.de" title="schreib mir"> </a></li> <!-- search form <form class='search' action='<?php //echo $pages->get('template=search')->url; ?>' method='get'> <input type='text' name='q' placeholder='Search' value='' /> <button type='submit' name='submit'>Search</button> </form> --> </ul> </nav> </div> _head.php
  15. Hi, I played around with my Mysql-database and because I did not remember that database-password, I entered a new one. After that my website throws an 'Internal server error'. Any help?
  16. @BillH Hi BillH, now your script does exactly what it is made for. Everything works fine, and I have learned more about PHP. Thanks a lot!
  17. @BillH Sorry, but I am not very familiar with php-programming, so I didn't find the right place where to add your patch to your convert-script. Would you be so kind to post the whole script? Günter
  18. @BillH Thanks again for your help, I will try your suggestion immediately. kind regards Günter
  19. @netcarver I asked my webhoster: scripts are limited at 300 seconds, but my script stops at less than 60 seconds. So I addet set_time_limit(300); ignore_user_abort(0); to my script, but this did not change anything. Greetings Günter
  20. Hi BillH, thank You for the great help. Now the script runs, but unfortunately it stops after doing half of its job
  21. Hi BillH, now I added your script to one of my templates and called it with my browser. As long as I leave the saves commented out it runs as desired, but if I try to save the changes it comes up with an "Internal Server Error"
  22. Some years ago I built a site with the help of the 'Image extra'-module. After some problems I decided to change to the modern way with a field-images-template. Now I want to copy the contents of that old Image-extra-field to my new fields. Is there a way to do that for all images at once?
×
×
  • Create New...