Last active
December 18, 2022 08:17
-
-
Save nmngt/56c740ae72dea10f43e8936f71f99f55 to your computer and use it in GitHub Desktop.
GetContaoFilePathInWordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_imagepath_from_contao() | |
{ | |
$wpdb_contao = new \wpdb('USER', 'PASSWORD', 'DBNAME', 'localhost'); | |
$result = $wpdb_contao->get_col(" | |
SELECT DISTINCT `product_imageSrc` | |
FROM `tl_zenner_products_language` | |
WHERE `id` = '1' | |
"); | |
// get_col() liefert ein Array mit binaerem Inhalt zurück. | |
$binaer = $result[0]; | |
// Contao arbeitet intern mit einem FileObject, welches pro Eintrag eine UUID vergibt und diese binaer speichert. | |
// Die Funktion zum umwandeln von binaer in die uuid habe ich mir im StringUtil von contao geborgt: | |
// https://github.com/contao/core-bundle/blob/4.x/src/Resources/contao/library/Contao/StringUtil.php | |
// | |
// Das aber nur zur Info.. Für den eigentlichen filepath benötigen wir die UUID nicht. Eventuell aber später. | |
$uuid = implode('-', unpack('H8time_low/H4time_mid/H4time_high/H4clock_seq/H12node', $binaer)); | |
if(false !== $uuid) | |
{ | |
$result = $wpdb_contao->get_col(" | |
SELECT DISTINCT `path` | |
FROM `tl_files` | |
AND `uuid` = '".$binaer."' | |
"); | |
var_dump($result); | |
die(); | |
} | |
} | |
get_imagepath_from_contao(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment