Salta al contenuto

Digitalia – Blog

a thoughtful use of digital

  • Home
  • android

Tag: metatags

Pubblicato il 22 Febbraio 202522 Febbraio 2025

avif metadata

To write metadata in avif image files with Digikam, you have to set it in

settings – > metadata -> behavior, as in the attached image:

Pubblicato il 20 Dicembre 202420 Dicembre 2024

folder’s metadata in php

You can add metadata to a website folder, i.g. adding in it a file, such as . folder, within write something like:

{
    "description": "your description",
    "order": 2
}

“order”: 2, in case you want that that folder be the second in your webpage

In the webpage you can retrieve the metadata info with a code like this:

<?php
$d = dir(".");
$folders = [];

// Array delle cartelle da escludere
$excludedDirs = ['excluded-dir', 'another-excluded-dir', 'yet-another-excluded-dir'];

while (false !== ($entry = $d->read())) {
    // Controlla se l'entry è una directory e non è una delle cartelle da escludere
    if (is_dir($entry) && ($entry != '.') && ($entry != '..') && !in_array($entry, $excludedDirs)) {
        $metadataFile = $entry . '/.directory';
        $metadata = [];

        // Recupera i metadati dal file .directory
        if (file_exists($metadataFile)) {
            $metadata = json_decode(file_get_contents($metadataFile), true); // Leggi e decodifica il contenuto del file
        }

        // Aggiungi la cartella e i metadati all'array
        $folders[] = [
            'name' => $entry,
            'displayName' => str_replace('-', ' ', $entry), // Sostituisci i trattini con spazi per la visualizzazione
            'order' => isset($metadata['order']) ? $metadata['order'] : PHP_INT_MAX, // Usa un valore alto se non è specificato
            'description' => isset($metadata['description']) ? $metadata['description'] : ''
        ];
    }
}

// Ordina le cartelle in base all'attributo 'order'
usort($folders, function($a, $b) {
    return $a['order'] <=> $b['order'];
});

echo "<h2>sotto-sezioni</h2>\n<ul>";
foreach ($folders as $folder) {
    echo "<li order='{$folder['order']}'><a  class='big' href='{$folder['name']}'>{$folder['displayName']}</a>";
    if ($folder['description']) {
        echo "<br /><p>{$folder['description']}</p>"; // Mostra la descrizione se presente
    }
    echo "</li>";
}
echo "</ul>";

$d->close();
?>
Pubblicato il 23 Ottobre 20244 Dicembre 2024

php list files and metadata

This is a good code:

<?php
echo "<ul class=\"flexmenu\">\n";
$phpfiles = glob("$path./[^index]*.php"); // Get all PHP files except index.php
foreach ($phpfiles as $phpfile) {
    $contents = file_get_contents($phpfile);

    preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatch);
    preg_match('/\$subtitle\s*=\s*"(.*?)";/', $contents, $subtitleMatch);
    preg_match('/\$description\s*=\s*"(.*?)";/', $contents, $descriptionMatch);
    preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatch);

    $title = $titleMatch[1] ?? 'No title';
    $subtitle = $subtitleMatch[1] ?? 'No subtitle';
    $order = $orderMatch[1] ?? '';
    $description = $descriptionMatch[1] ?? 'No description';

    // Correctly extract the filename
     $filename = $phpfile; // Use basename on $phpfile directly
    echo " <li role='menuitem' style=\"order:$order\"><a href=\"{$filename}\">{$title}</a>, <i>{$subtitle}</i>: {$description}</li>\n";
}
echo "</ul>";
?>

You can get the title of your files in that folder (useful if the name of the file would not suit for a list), the subtitle and description.
With the order variable you can set, in a flex list (and this is why is added a .flexmenu class: a no-flex list doesn’t order your items as expected, but alphabetically), in what order your files should appear.
Of course the title is linked with the matching file.

Meta

  • Accedi
  • Feed dei contenuti
  • Feed dei commenti
  • WordPress.org

back to website

vai al sito

Articoli recenti

  • Thunderbird – Whatsapp problem
  • Automatically list wp posts
  • MTP problems (android – PC cable connection)
  • Regex in Kate convert in lowercase
  • copyq problems
  • Php variables in WordPress
  • Markdown editors
  • Set date format in Thunderbird mail list
  • Thunderbird task manager icon
  • Fix a corrupt innodb

Tag

  • android (8)
  • autokey (7)
  • avidemux (5)
  • boot (5)
  • browsers (10)
  • Chrome (6)
  • css (10)
  • css3 (8)
  • Dolphin (10)
  • expand/collapse (5)
  • facebook (6)
  • Firefox (16)
  • google (6)
  • grub (5)
  • html editor (7)
  • IE (5)
  • image (7)
  • innodb (6)
  • javascript (8)
  • kate (8)
  • kde (7)
  • lampp (5)
  • libreoffice (16)
  • LibreWriter (13)
  • linux (30)
  • localhost (7)
  • MariaDB (7)
  • metadata (5)
  • mysql (37)
  • openoffice (8)
  • open source (7)
  • pclinuxos (5)
  • pdf (9)
  • php (15)
  • phpmyadmin (5)
  • regex (17)
  • replace (5)
  • snap (5)
  • svg (11)
  • syncronization (5)
  • tags (7)
  • thunderbird (16)
  • ubuntu (6)
  • UTF-8 (5)
  • Wordpress (14)

Categorie

  • android
  • apache
  • audio
  • blogs
  • boot
  • browsers
  • clouds
  • code
  • connectivity
  • css
  • database
  • decoder – media player
  • desktop grafico
  • digit-alia
  • email
  • epub
  • graphics
  • internet
  • javascript
  • librecalc
  • linux
  • markdown
  • markdown
  • multimedia
  • network
  • network
  • office
  • partitions
  • pdf
  • periferiche
  • phone
  • php
  • router
  • samba
  • Senza categoria
  • sistema operativo
  • smartphone
  • social
  • text
  • tools
  • usb
  • video
  • webmaster
  • writer

Archivi

  • Luglio 2026
  • Giugno 2026
  • Maggio 2026
  • Aprile 2026
  • Marzo 2026
  • Febbraio 2026
  • Gennaio 2026
  • Dicembre 2025
  • Novembre 2025
  • Ottobre 2025
  • Agosto 2025
  • Luglio 2025
  • Giugno 2025
  • Maggio 2025
  • Aprile 2025
  • Marzo 2025
  • Febbraio 2025
  • Gennaio 2025
  • Dicembre 2024
  • Novembre 2024
  • Ottobre 2024
  • Settembre 2024
  • Agosto 2024
  • Luglio 2024
  • Giugno 2024
  • Maggio 2024
  • Aprile 2024
  • Marzo 2024
  • Febbraio 2024
  • Gennaio 2024
  • Dicembre 2023
  • Novembre 2023
  • Ottobre 2023
  • Settembre 2023
  • Agosto 2023
  • Giugno 2023
  • Maggio 2023
  • Aprile 2023
  • Marzo 2023
  • Febbraio 2023
  • Gennaio 2023
  • Dicembre 2022
  • Novembre 2022
  • Ottobre 2022
  • Settembre 2022
  • Agosto 2022
  • Luglio 2022
  • Giugno 2022
  • Maggio 2022
  • Aprile 2022
  • Marzo 2022
  • Febbraio 2022
  • Gennaio 2022
  • Dicembre 2021
  • Novembre 2021
  • Ottobre 2021
  • Settembre 2021
  • Luglio 2021
  • Giugno 2021
  • Maggio 2021
  • Marzo 2021
  • Febbraio 2021
  • Gennaio 2021
  • Dicembre 2020
  • Novembre 2020
  • Ottobre 2020
  • Settembre 2020
  • Agosto 2020
  • Luglio 2020
  • Giugno 2020
  • Maggio 2020
  • Aprile 2020
  • Marzo 2020
  • Febbraio 2020
  • Novembre 2019
  • Ottobre 2019
  • Settembre 2019
  • Agosto 2019
  • Luglio 2019
  • Giugno 2019
  • Aprile 2019
  • Marzo 2019
  • Febbraio 2019
  • Gennaio 2019
  • Dicembre 2018
  • Novembre 2018
  • Settembre 2018
  • Agosto 2018
  • Luglio 2018
  • Giugno 2018
  • Maggio 2018
  • Aprile 2018
  • Marzo 2018
  • Febbraio 2018
  • Gennaio 2018
  • Dicembre 2017
  • Novembre 2017
  • Ottobre 2017
  • Settembre 2017
  • Giugno 2017
  • Maggio 2017
  • Aprile 2017
  • Marzo 2017
  • Febbraio 2017
  • Gennaio 2017
  • Dicembre 2016
  • Novembre 2016
  • Ottobre 2016
  • Agosto 2016
  • Giugno 2016
  • Maggio 2016
  • Aprile 2016
  • Marzo 2016
  • Agosto 2015
  • Maggio 2015
  • Gennaio 2015
  • Ottobre 2014
  • Agosto 2014
  • Giugno 2014
  • Aprile 2014
  • Marzo 2014
  • Febbraio 2014
  • Gennaio 2014
  • Novembre 2013
  • Settembre 2013
  • Luglio 2013
  • Giugno 2013
  • Aprile 2013
  • Marzo 2013
  • Febbraio 2013
  • Dicembre 2012
  • Novembre 2012
  • Settembre 2012
  • Agosto 2012
  • Luglio 2012
  • Gennaio 2012
  • Novembre 2011
  • Ottobre 2011
  • Agosto 2011
  • Luglio 2011
  • Giugno 2011
  • Marzo 2011
  • Agosto 2010
  • Giugno 2010
  • Maggio 2010
  • Aprile 2010
  • Marzo 2010
  • Febbraio 2010
  • Gennaio 2010

Categorie

  • android
  • apache
  • audio
  • blogs
  • boot
  • browsers
  • clouds
  • code
  • connectivity
  • css
  • database
  • decoder – media player
  • desktop grafico
  • digit-alia
  • email
  • epub
  • graphics
  • internet
  • javascript
  • librecalc
  • linux
  • markdown
  • markdown
  • multimedia
  • network
  • network
  • office
  • partitions
  • pdf
  • periferiche
  • phone
  • php
  • router
  • samba
  • Senza categoria
  • sistema operativo
  • smartphone
  • social
  • text
  • tools
  • usb
  • video
  • webmaster
  • writer

Meta

  • Accedi
  • Feed dei contenuti
  • Feed dei commenti
  • WordPress.org
Proudly powered by WordPress