Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by biber

  1. 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

  2. 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:


    Warning: foreach() argument must be of type array|object, string given in /var/www/html/processwire/processwire-master/site/templates/galerie.php on line 53

    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 ?>
    3 <div id='haupt'>
    5 <?php
    7 // output 'headline' if available, otherwise 'title'
    8 echo '<h1>' . $page->get('headline|title') . '</h1>';
    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);
    15 //check for the second urlsegment not needed
    16 if ($seg2) {
    17 // unknown URL segment, send a 404
    18 throw new \ProcessWire\Wire404Exception();
    19 }
    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;
    29 // sortiere nach name_:
    30 if ($order >0) {
    31 $images = $page->images->sort("iname_".$order, SORT_NATURAL |
    32 $session->set($order, $order);
    33 }
    35 // ohne Sortierung:
    36 else {
    37 $images = $page->images;
    38 }
    40 //normal content without first url segment!
    41 if (!$seg1) {
    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').
    47 if (!empty($page->name_2))
    48 echo '<a class="tab " href="'.$page->url.'?order=2">'. $page->get('name_2').
    49 if (!empty($page->name_3))
    50 echo '<a class="tab " href="'.$page->url.'?order=3">'. $page->get('name_3').
    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 }
    59 }
    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);
    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;';
    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;';
    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 />';
    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').'">';
    79 //echo '<img class="shadow" src="'.$images->url. $seg1.'" 
    alt="'.$images->$seg1->kopf.'" title="'.$images->$seg1->get('name_1|kopf').'">'; 
    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 ?>


  3. 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?

  4. 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


  5. 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:


  6. 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:


  7. 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'

  8. Hi,

    I copied my website malabu.de on a local LAMP-server which runs PHP 8.2.7 and got the following Fatal Error:


    Uncaught TypeError: visit(): Argument #1 ($parent) must be of type Page, HomePage given, called in site/templates/_head.php on line 53 and defined in site/templates/_head.php:36

    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">
        <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" />
    	<!-- navigation -->
    <div id="menu">
    <h1 class="titel"><a href="/">malabu.de</a></h1>
    <nav id="nav">
    		// top navigation consists of homepage and its visible children
    		$homepage = $pages->get('/'); 
    		$children = $homepage->children();
    		// make 'home' the first item in the navigation
     * 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);
        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">
    		<!-- 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>



  • Create New...