I get it, ich habe die allgemeinen Hinweise übersprungen und das Forum zu spezifisch durchsucht.. so rum kann man es natürlich auch falsch machen – sorry!
Ich hab mal die firmeninternen Dinge rausgeworfen und das Template angehängt:
PHP-Code:
<?php
$pathToCSS = "style.css";
?>
<div class="myCustomTemplate">
<style>
.myCustomTemplate {
padding: 2rem 0;
position: relative;
float: left;
}
.myCustomTemplate #mycode-<?= $this->data['0']['raw']['articlenumber'] ?> {
height: 0;
width: 0;
opacity: 0;
}
.myCustomTemplate #copy-<?= $this->data['0']['raw']['articlenumber'] ?> {
margin-top: 0;
}
.myCustomTemplate #copied-<?= $this->data['0']['raw']['articlenumber'] ?> {
position: absolute;
left: 0;
bottom: 1.6rem;
}
.js--copynote {
opacity: 0;
transition: all ease .2s;
pointer-events: none;
}
.js--copynote.js--visible {
opacity: 1;
}
</style>
<?php if ($this->data['0']['raw']['name']): ?>
<h3><?= $this->data['0']['raw']['name'] ?></h3>
<?php endif; ?>
<p><?= $this->data['0']['raw']['articlenumber'] ?></p>
<textarea id="mycode-<?= $this->data['0']['raw']['articlenumber'] ?>" readonly>
<html>
<head>
<meta name="version" content="1.0.0">
<meta name="lastmodified" content="<?= date("d.m.Y - H:i", $this->data['0']['raw']['tstamp']) ?>">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=yes">
<link rel="stylesheet" href="<?= $pathToCSS ?>">
</head>
<body>
<div class="content-main">
<div class="header-main">
{{insert_node::5}}
</div>
<div class="container--top wrapper--inner">
<div class="inner box">
<?php if ($this->data['0']['raw']['name']): ?>
<h1><?= $this->data['0']['raw']['name'] ?></h1>
<?php endif; ?>
<?php // BILDER // ?>
<div class="container--images">
<div class="image--view">
<?php
if ($this->data['0']['raw']['mm_articleimages']) {
$i = 1;
foreach ($this->data['0']['raw']['mm_articleimages']['path_sorted'] as $imgpath) {
if ($i == 1) {$checked = " checked";}else{$checked = "";}
echo "<input".$checked." type=\"radio\" id=\"img-".$i."\" name=\"select--images\">";
echo "<label for=\"zoomimg-".$i."\"><img src=\"".$imgpath."\"><input type=\"radio\" id=\"zoomimg-".$i."\" name=\"zoom--images\"><div class=\"zoomimg\"><img src=\"".$imgpath."\"><input type=\"radio\" id=\"close\" name=\"zoom--images\"></div></label>";
$i++;
}
}
?>
</div>
<div class="container--thumbnails">
<?php
if ($this->data['0']['raw']['mm_articleimages']) {
$j = 1;
foreach ($this->data['0']['raw']['mm_articleimages']['path_sorted'] as $imgpath) {
echo "<label for=\"img-".$j."\"><img src=\"".$imgpath."\" width=\"100\" height=\"100>\"></label>";
$j++;
}
}
?>
</div>
</div>
<div class="container--buybox">
<?php // PREIS // ?>
<div class="container--buy">
<div class="container--price">
<?php if ($this->data['0']['raw']['price']): ?>
<p class="price"><?= number_format($this->data['0']['raw']['price'], 2, ",", ".") ?> € <?php if ($this->data['0']['raw']['pricetext']): ?><span><?= $this->data['0']['raw']['pricetext'] ?></span><?php endif; ?></p>
<?php endif; ?>
<?php if ($this->data['0']['raw']['delivery']): ?>
<p class="shipping">zzgl. Versand (siehe Bestellablauf)<br><?= $this->data['0']['raw']['delivery'] ?></p>
<?php endif; ?>
</div>
</div>
<?php // MERKMALE // ?>
<?php if ($this->data['0']['raw']['features']): ?>
<ul class="list">
<?php
foreach ($this->data['0']['raw']['features'] as $feature) {
foreach ($feature as $inner) {
echo "<li>".$inner["value"]."</li>";
}
}
?>
</ul>
<?php endif; ?>
<?php // GROESSE // ?>
<?php if ($this->data['0']['raw']['size']): ?>
<ul>
<?php
foreach ($this->data['0']['raw']['size'] as $feature) {
foreach ($feature as $inner) {
echo "<li>".$inner["value"]."</li>";
}
}
?>
</ul>
<?php endif; ?>
<?php // START FARBEN // ?>
<div class="container--colors">
<?php if ($this->data['0']['raw']['farbe1']): ?>
<div>
<p>Verfügbare Farben:</p>
<ul>
<?php
foreach ($this->data['0']['raw']['farbe1'] as $items) {
foreach ($items as $inner) {
if (is_numeric($inner['id']) && !is_numeric($inner['name'])) {
echo "<li>";
echo "<p class=\"title\">".$inner['name']."<span class=\"number\">".$inner['colornumber']."</span></p>";
if ($inner['image']['path'] != null) {
echo "<img width=\"50\" height=\"50\" src=\"".$inner['image']['path'][0]."\">";
}
echo "</li>";
}
}
}
?>
</ul>
</div>
<?php endif; ?>
<?php if ($this->data['0']['raw']['farbe2']): ?>
<div>
<p>xxxxx:</p>
<ul>
<?php
foreach ($this->data['0']['raw']['farbe2'] as $items) {
foreach ($items as $inner) {
if (is_numeric($inner['id']) && !is_numeric($inner['name'])) {
echo "<li>";
echo "<p class=\"title\">".$inner['name']."<span class=\"number\">".$inner['colornumber']."</span></p>";
if ($inner['image']['path'] != null) {
echo "<img width=\"50\" height=\"50\" src=\"".$inner['image']['path'][0]."\">";
}
echo "</li>";
}
}
}
?>
</ul>
</div>
<?php endif; ?>
</div>
<?php // END FARBEN // ?>
</div>
</div>
</div>
<?php // TABS // ?>
<div class="container--tabs wrapper--inner">
<div class="inner box">
<div class="tabs">
<?php if ($this->data['0']['raw']['tabcontent01']): ?>
<input type="radio" name="select--tabs" id="tab-01" class="is--hidden" checked>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent01']): ?>
<input type="radio" name="select--tabs" id="tab-02" class="is--hidden">
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent01']): ?>
<input type="radio" name="select--tabs" id="tab-03" class="is--hidden">
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent01']): ?>
<input type="radio" name="select--tabs" id="tab-04" class="is--hidden">
<?php endif; ?>
<div class="tabs--nav">
<?php if ($this->data['0']['raw']['tabtitle01']): ?>
<label class="label-01" for="tab-01"><?= $this->data['0']['raw']['tabtitle01'] ?></label>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabtitle01']): ?>
<label class="label-02" for="tab-02"><?= $this->data['0']['raw']['tabtitle02'] ?></label>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabtitle01']): ?>
<label class="label-03" for="tab-03"><?= $this->data['0']['raw']['tabtitle03'] ?></label>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabtitle01']): ?>
<label class="label-04" for="tab-04"><?= $this->data['0']['raw']['tabtitle04'] ?></label>
<?php endif; ?>
</div>
<?php if ($this->data['0']['raw']['tabcontent01']): ?>
<div class="tab--content content-01<?php if ($this->data['0']['raw']['featurestable']): ?> has--table<?php endif; ?>">
<div class="inner">
<?= $this->data['0']['raw']['tabcontent01'] ?>
</div>
<?php // FEATURES TABLE // ?>
<?php if ($this->data['0']['raw']['featurestable']): ?>
<div class="featurestable">
<ul>
<?php
foreach ($this->data['0']['raw']['featurestable'] as $feature) {
echo "<li>";
$i = 0;
foreach ($feature as $inner) {
echo "<span>".$inner['value']."</span>";
}
echo "</li>";
}
?>
</ul>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent02']): ?>
<div class="tab--content content-02">
<div class="inner">
<?= $this->data['0']['raw']['tabcontent02'] ?>
</div>
</div>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent03']): ?>
<div class="tab--content content-03">
<div class="inner">
<?= $this->data['0']['raw']['tabcontent03'] ?>
</div>
</div>
<?php endif; ?>
<?php if ($this->data['0']['raw']['tabcontent04']): ?>
<div class="tab--content content-04">
<div class="inner">
<?= $this->data['0']['raw']['tabcontent04'] ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php // BANNER // ?>
<div class="content--banner wrapper--inner">
<div class="inner box">
{{insert_node::6}}
</div>
</div>
<?php // CROSSSELLING // ?>
<?php if ($this->data['0']['raw']['crosssellingitems']): ?>
<div class="container--crossselling wrapper--inner">
<h4>Ähnliche Artikel</h4>
<div class="inner box">
<?php
foreach ($this->data['0']['raw']['crosssellingitems'] as $item) {
echo "<div class=\"item\">";
if ($item['mm_articleimages'] != null) {
echo "<img width=\"200\" height=\"200\" src=\"".$this->data['0']['raw']['mm_articleimages']['path_sorted'][0]."\">";
}
echo "<p class=\"name\">".$item['name']."</p>";
echo "<p class=\"btn\">Zum Artikel</p>";
echo "</div>";
}
?>
</div>
</div>
<?php endif; ?>
<?php // CARDS // ?>
<div class="content--cards wrapper--inner">
<div class="inner">
{{insert_node::7}}
</div>
</div>
<?php // FOOTER // ?>
<div class="footer-main wrapper--inner">
{{insert_node::8}}
</div>
<?php // MOBILE DESCRIPTION // ?>
<div style="display:none;" vocab="https://schema.org/" typeof="Product" class="mobiledescription">
<span property="description">
<?php // MERKMALE // ?>
<?php if ($this->data['0']['raw']['features']): ?>
<ul class="list">
<?php
foreach ($this->data['0']['raw']['features'] as $feature) {
foreach ($feature as $inner) {
echo "<li>".$inner["value"]."</li>";
}
}
?>
</ul>
<?php endif; ?>
</span>
</div>
<div style="display:none;">
<span data-color="#E52C87" data-bgcolor="#FFFFFF" data-hvcolor="#3F3F3F" data-version="1.8.0" data-name="Actum" data-artnr="<?= $this->data['0']['raw']['articlenumber']?>"></span>
</div>
</div>
</body>
</html>
</textarea>
<br>
<button class="btn" id="copy-<?= $this->data['0']['raw']['articlenumber'] ?>">Template kopieren</button>
<br><br>
<p id="copied-<?= $this->data['0']['raw']['articlenumber'] ?>" class=" js--copynote">Template in Zwischenablage kopiert</p>
<script>
$("#copy-<?= $this->data['0']['raw']['articlenumber'] ?>").click(function(){
$("#mycode-<?= $this->data['0']['raw']['articlenumber'] ?>").select();
document.execCommand('copy');
setTimeout(function(){
$("#copied-<?= $this->data['0']['raw']['articlenumber'] ?>").addClass("js--visible");
}, 80);
setTimeout(function(){
$("#copied-<?= $this->data['0']['raw']['articlenumber'] ?>").removeClass('js--visible');
}, 3000);
});
</script>
</div>
Man verzeihe mir ggf. meinen PHP-Code, als Quereinsteiger bin ich froh, wenn es läuft
Hintergrund: ich nutze MetaModels als Templategenerator aus einem Produktkatalog heraus, daher landet das meiste innerhalb der textarea und ist zusätzlich mit Nodes und JS versehen.
Das geht aber vermutlich wieder zu tief, als dass ich da Hilfe erwarten würde.
Gibt es noch eine Möglichkeit die MetaModels Einstellungen zu exportieren, hilft es (mir) wenn ich Screens mache?
Oder angesichts des Hinweises, könnte ich auch gleich ein weiteres Contao 4.4 aufsetzen.
Lesezeichen