Ergebnis 1 bis 5 von 5

Thema: Import Catalog element

  1. #1
    Contao-Nutzer Avatar von Paolob
    Registriert seit
    29.12.2011.
    Beiträge
    23

    Frage Import Catalog element

    Hi
    Should I convert a site with some archives Catalog
    I created the new MataModels with the same fields, and now I have to import the data.

    In the catalog I have a file field, where I have the file path. In the field MetaModels file is a Blob.
    How can I convert this information also using PHP?

    Thanks
    Paolo B.
    Contao ambassador
    ContaoCms.it - Sito di riferimento per la comunità italiana

  2. #2
    Contao-Nutzer Avatar von YuriOrlovBtf
    Registriert seit
    14.09.2012.
    Beiträge
    40

    Standard use contao build in functions

    Hey,

    use the contao build-in functions.
    Here are the functions for your own "dirty-non-prepared-statements-import-script":


    PHP-Code:
    /**
         * Convert a UUID string to binary data
         *
         * @param string $uuid The UUID string
         *
         * @return string The binary data
         */
        
    function uuidToBin($uuid)
        {
            return 
    pack('H*'str_replace('-'''$uuid));
        }


    /**
         * Get a UUID string from binary data
         *
         * @param string $data The binary data
         *
         * @return string The UUID string
         */
        
    function binToUuid($data)
        {
        return 
    implode('-'unpack('H8time_low/H4time_mid/H4time_high/H4clock_seq/H12node'$data));
        } 

  3. #3
    Contao-Nutzer Avatar von Paolob
    Registriert seit
    29.12.2011.
    Beiträge
    23

    Standard

    Zitat Zitat von YuriOrlovBtf Beitrag anzeigen
    Hey,

    use the contao build-in functions.
    Perfect, thanks for the tip.

    Can I calculate the UUID of the file having the file path?
    Paolo B.
    Contao ambassador
    ContaoCms.it - Sito di riferimento per la comunità italiana

  4. #4
    Contao-Nutzer Avatar von YuriOrlovBtf
    Registriert seit
    14.09.2012.
    Beiträge
    40

    Standard yes, we can!

    Zitat Zitat von Paolob Beitrag anzeigen
    Perfect, thanks for the tip.

    Can I calculate the UUID of the file having the file path?

    1. copy all your Files from Catalog/contao2 (tl_files/) to contao3 (files/)
    2. in Contao3 Backend, run the Syncroutine (see attached picture)
    Unbenannt.png

    3. use this dirty-function to retrive the uuid by catalog-path as parameter.

    PHP-Code:
    /**
    * return the uuid by given catalog-filepath
    * usaeage: getBinUuidByPath('tl_files/john/doo/fooBar.png');
    */
    function getBinUuidByPath($TLpath) {

        
    $picQ mysql_query("SELECT uuid FROM tl_files WHERE path = '".substr($TLpath,3)."' 
                     AND extension != ''"
    );
        
    $result mysql_fetch_array($picQ);

        if(
    mysql_num_rows($picQ) == 1)
            return 
    $result['uuid'];

        else    
            return 
    false;



  5. #5
    Contao-Nutzer Avatar von Paolob
    Registriert seit
    29.12.2011.
    Beiträge
    23

    Standard

    Zitat Zitat von YuriOrlovBtf Beitrag anzeigen
    3. use this dirty-function to retrive the uuid by catalog-path as parameter.
    I had thought about going to read the table tl_file, but I thought there was a different way.

    thanks
    Paolo B.
    Contao ambassador
    ContaoCms.it - Sito di riferimento per la comunità italiana

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •