Liste der Anhänge anzeigen (Anzahl: 1)
Contao 4.4.0 - Seiten und Artikel ID im Backend anzeigen geht auch
Guten Morgen
Die Seiten- und Artikel ID kann man auch bei Contao 4.4.0 im Backend anzeigen lassen. Dazu nach system/config eine/oder die von Contao 3.5.x dcaconfig.php kopieren.
Inhalt von dcaconfig.php
Code:
<?php
// Put your custom configuration here
### Show page id
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'id';
$GLOBALS['TL_DCA']['tl_page']['list']['label']['format'] = '%s <span style="color: #960000 !important; font-weight:normal; padding-left: 3px;">[ID: %s]</span>';
### Show article id
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'id';
$GLOBALS['TL_DCA']['tl_article']['list']['label']['format'] = '%s <span style="color: #960000 !important; font-weight:normal; padding-left: 3px;">[%s, ID: %s]</span>';
?>
Finde ich zum Arbeiten ausserordentlich hilfreich und sollte eigentlich bei Contao 4.4.x endlich implementiert sein.
pumukel
Liste der Anhänge anzeigen (Anzahl: 2)
Dafür gibt es auch eine Erweiterung [summary].
Ich persönlich sehe dort lieber das Pagelayout, falls ausgewählt, die CSS-Klasse und den Alias. Die ID interessiert mich nicht, die sehe ich auch bei Mouse-Over.
Anhang 19579
Anhang 19580
(Die Screenshots sind von meiner Spielwiese.)
Ich mache das auch über eine Anpassung.
PHP-Code:
/**
* Format some listviews (works together with _my_be.js and _my_be.css included by initconfig.php)
*/
// Show page alias in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'alias';
// Show page layout in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'includeLayout';
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'layout:tl_layout.name';
// Show page cssClass in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'cssClass';
// Page listview format
$GLOBALS['TL_DCA']['tl_page']['list']['label']['format'] = '
%s <span class="page_alias" title="alias">%s</span>
<span class="page_layout" data-l="%.3s" title="layout">%s</span>
<span class="page_cssClass" title="cssClass">%s</span>
';
// Show article cssID in article listview
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'cssID';
// Show article alias in article listview
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'alias';
// Article listview format
$GLOBALS['TL_DCA']['tl_article']['list']['label']['format'] = '
<span class="article_format">
<span class="article_title" title="%1$s">%4$s</span>
<span class="article_section" title="Show in">%2$s</span>
<span class="article_cssId">%3$s</span>
</span>
';
Für die Aufbereitung des Layouts und bei den Artikeln des serialisierten css-id-class Arrays bedarf es noch einiges an JS.
Liste der Anhänge anzeigen (Anzahl: 2)
Contao 4.4.20 - Seiten und Artikel ID im Backend anzeigen
Also ich hab das mal probiert wie folgt in Contao 4.4.20 umzusetzen
Ich hab als erstes unter /app/Resources/contao/ den Ordner dca erstellt, danach darin die beiden
Dateien tl_article.php und tl_page.php angelegt.
Inhalt tl_article.php
PHP-Code:
// Show article cssID in article listview
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'cssID';
// Show article alias in article listview
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'alias';
// Article listview format
$GLOBALS['TL_DCA']['tl_article']['list']['label']['format'] = '
<span class="article_format">
<span class="article_title" title="%1$s">%4$s</span>
<span class="article_section" title="Show in">%2$s</span>
<span class="article_cssId">%3$s</span>
</span>
';
Inhalt tl_page.php
PHP-Code:
/**
* Format some listviews (works together with _my_be.js and _my_be.css included by initconfig.php)
*/
// Show page alias in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'alias';
// Show page layout in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'includeLayout';
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'layout:tl_layout.name';
// Show page cssClass in page listview
$GLOBALS['TL_DCA']['tl_page']['list']['label']['fields'][] = 'cssClass';
// Page listview format
$GLOBALS['TL_DCA']['tl_page']['list']['label']['format'] = '
%s <span class="page_alias" title="alias">%s</span>
<span class="page_layout" data-l="%.3s" title="layout">%s</span>
<span class="page_cssClass" title="cssClass">%s</span>
';
Weiters habe ich die beiden Dateien my_be.css und my_be.js angelegt und in folgendem
Ordner abgelegt /system/themes/flexible/
Inhalt my_be.css
PHP-Code:
/* ... Article listview ... (only works with _my_be.js and appropriate dcaconfig settings)
-------------------------------------------------------------------------------------------------*/
.tl_listing [id^='tl_article_tl_page_tree_'] .tl_left {
position: relative;
}
#top ul.tl_tree_xtnd li.tl_folder_top div.tl_left,
#top ul.tl_tree_xtnd li.tl_folder div.tl_left {
box-sizing: border-box;
width: 620px;
}
.article_format {
display: block;
margin-top: -17px;
text-indent: 0;
cursor: default;
}
.article_title,
.article_section,
.article_id,
.article_css {
float: left;
padding-right: .5em;
cursor: help;
}
.article_title {
color: #b05701;
}
.article_title:empty:before {
content: "no alias";
color: #CB7474;
}
.article_section {
color: #aaa;
}
.article_cssId {
float: left;
}
.article_id {
color: #70A6CB;
}
.article_css {
color: #72CB73;
}
/* ... Article listview ... END
-------------------------------------------------------------------------------------------------*/
/* ... Page listview ... (only works with _my_be.js and appropriate dcaconfig settings)
-------------------------------------------------------------------------------------------------*/
.page_cssClass:empty,
.page_layout {
display: none;
}
.page_layout.has_layout {
display: inline;
}
.page_alias,
.page_cssClass,
.page_layout {
cursor: help;
white-space: nowrap;
font-weight: normal;
}
.page_alias {
color: #aaa;
}
.page_alias:empty:before {
content: "no alias";
color: #CB7474;
}
.page_cssClass {
color: #72CB73;
}
.page_layout {
background-color: #aaa;
border-radius: 2px;
color: #fff;
padding: 0 2px;
font-size: 10px;
}
/* ... Page listview ... END
-------------------------------------------------------------------------------------------------*/
Inhalt my_be.js
PHP-Code:
/**
* files/js/_my_be.js
*/
(function($) {
window.addEvent('domready', function() {
// format article listview (only works with appropriate modified article list view in dcaconfig and appropriate _my_be.css)
var
init,
myCssIds,
oldText,
arrNewText,
newText
;
init = function(){
myCssIds = $$('.article_cssId');
// Split CssId into an object
myCssIds.each(function(item){
oldText = item.get('text');
if(oldText && oldText.length >= 29){
newText = '';
arrNewText = (oldText.slice(0, 2) == 'a:') ? unserialize(oldText) : oldText;
if(arrNewText[0]){
newText += '<span class="article_id" title="CSS-ID">' + arrNewText[0] + ' </span>';
}
if(arrNewText[1]){
newText += '<span class="article_css" title="CSS-Class">' + arrNewText[1] + '</span>';
}
item.set('html', newText);
}
else{
item.dispose();
}
});
};
// on document ready
init();
// after ajax manipulation
window.addEvent('ajax_change', init);
// format page treeview layout sticker (only works with appropriate modified page list view in dcaconfig and appropriate _my_be.css)
styleLayoutPicker = function(){
var layoutSticker = $$('.page_layout:not(:empty):not([data-l=""])') || false;
if(layoutSticker){
var stringToColour = function(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var colour = '#';
for (var i = 0; i < 3; i++) {
var value = (hash >> (i * 8)) & 0xFF;
colour += ('00' + value.toString(16)).substr(-2);
}
return colour;
}
Array.each(layoutSticker, function(item){
item.addClass('has_layout');
var bgColor = new Color (stringToColour(item.get('text')));
var brightness = Math.sqrt((.299 * Math.pow(bgColor[0], 2)) + (.587 * Math.pow(bgColor[1], 2)) + (.114 * Math.pow(bgColor[2], 2)));
var color = brightness > 190 ? '#000' : '#fff';
item.setStyles({
'background-color': bgColor,
color: color
});
});
}
}
styleLayoutPicker();
window.addEvent('ajax_change', styleLayoutPicker);
});
})(document.id);
// Class from phpjs.org
function unserialize(data) {
// discuss at: http://phpjs.org/functions/unserialize/
// original by: Arpad Ray (mailto:arpad@php.net)
// improved by: Pedro Tainha (http://www.pedrotainha.com)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Chris
// improved by: James
// improved by: Le Torbi
// improved by: Eli Skeggs
// bugfixed by: dptr1988
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// revised by: d3x
// input by: Brett Zamir (http://brett-zamir.me)
// input by: Martin (http://www.erlenwiese.de/)
// input by: kilops
// input by: Jaroslaw Czarniak
// note: We feel the main purpose of this function should be to ease the transport of data between php & js
// note: Aiming for PHP-compatibility, we have to translate objects to arrays
// example 1: unserialize('a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}');
// returns 1: ['Kevin', 'van', 'Zonneveld']
// example 2: unserialize('a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}');
// returns 2: {firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'}
var that = this,
utf8Overhead = function (chr) {
// http://phpjs.org/functions/unserialize:571#comment_95906
var code = chr.charCodeAt(0);
if (code < 0x0080) {
return 0;
}
if (code < 0x0800) {
return 1;
}
return 2;
};
error = function (type, msg, filename, line) {
throw new that.window[type](msg, filename, line);
};
read_until = function (data, offset, stopchr) {
var i = 2,
buf = [],
chr = data.slice(offset, offset + 1);
while (chr != stopchr) {
if ((i + offset) > data.length) {
error('Error', 'Invalid');
}
buf.push(chr);
chr = data.slice(offset + (i - 1), offset + i);
i += 1;
}
return [buf.length, buf.join('')];
};
read_chrs = function (data, offset, length) {
var i, chr, buf;
buf = [];
for (i = 0; i < length; i++) {
chr = data.slice(offset + (i - 1), offset + i);
buf.push(chr);
length -= utf8Overhead(chr);
}
return [buf.length, buf.join('')];
};
_unserialize = function (data, offset) {
var dtype, dataoffset, keyandchrs, keys, contig,
length, array, readdata, readData, ccount,
stringlength, i, key, kprops, kchrs, vprops,
vchrs, value, chrs = 0,
typeconvert = function (x) {
return x;
};
if (!offset) {
offset = 0;
}
dtype = (data.slice(offset, offset + 1))
.toLowerCase();
dataoffset = offset + 2;
switch (dtype) {
case 'i':
typeconvert = function (x) {
return parseInt(x, 10);
};
readData = read_until(data, dataoffset, ';');
chrs = readData[0];
readdata = readData[1];
dataoffset += chrs + 1;
break;
case 'b':
typeconvert = function (x) {
return parseInt(x, 10) !== 0;
};
readData = read_until(data, dataoffset, ';');
chrs = readData[0];
readdata = readData[1];
dataoffset += chrs + 1;
break;
case 'd':
typeconvert = function (x) {
return parseFloat(x);
};
readData = read_until(data, dataoffset, ';');
chrs = readData[0];
readdata = readData[1];
dataoffset += chrs + 1;
break;
case 'n':
readdata = null;
break;
case 's':
ccount = read_until(data, dataoffset, ':');
chrs = ccount[0];
stringlength = ccount[1];
dataoffset += chrs + 2;
readData = read_chrs(data, dataoffset + 1, parseInt(stringlength, 10));
chrs = readData[0];
readdata = readData[1];
dataoffset += chrs + 2;
if (chrs != parseInt(stringlength, 10) && chrs != readdata.length) {
error('SyntaxError', 'String length mismatch');
}
break;
case 'a':
readdata = {};
keyandchrs = read_until(data, dataoffset, ':');
chrs = keyandchrs[0];
keys = keyandchrs[1];
dataoffset += chrs + 2;
length = parseInt(keys, 10);
contig = true;
for (i = 0; i < length; i++) {
kprops = _unserialize(data, dataoffset);
kchrs = kprops[1];
key = kprops[2];
dataoffset += kchrs;
vprops = _unserialize(data, dataoffset);
vchrs = vprops[1];
value = vprops[2];
dataoffset += vchrs;
if (key !== i)
contig = false;
readdata[key] = value;
}
if (contig) {
array = new Array(length);
for (i = 0; i < length; i++)
array[i] = readdata[i];
readdata = array;
}
dataoffset += 1;
break;
default:
error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
break;
}
return [dtype, dataoffset - offset, typeconvert(readdata)];
};
return _unserialize((data + ''), 0)[2];
}
Danach im BE unter Templates noch eine Kopie des be_main.html5 erstellt (wichtig dabei ist, dass der
Namen des Templates genau so belassen wird).
Das be_main.html5 noch wie folgt anpassen (das rot markierte ist einzufügen)
Code:
<head>
<meta charset="<?= $this->charset ?>">
<title><?= $this->title ?> - Contao Open Source CMS</title>
<base href="<?= $this->base ?>">
<meta name="generator" content="Contao Open Source CMS">
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
<meta name="referrer" content="origin">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/fonts.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>assets/colorpicker/css/mooRainbow.min.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>assets/chosen/css/chosen.min.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>assets/simplemodal/css/simplemodal.min.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>assets/datepicker/css/datepicker.min.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/basic.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/main.css">
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/my_be.css">
<?= $this->stylesheets ?>
<script><?= $this->getLocaleString() ?></script>
<script src="<?= TL_ASSETS_URL ?>assets/mootools/js/mootools.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>assets/colorpicker/js/mooRainbow.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>assets/chosen/js/chosen.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>assets/simplemodal/js/simplemodal.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>assets/datepicker/js/datepicker.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>bundles/contaocore/mootao.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>bundles/contaocore/core.min.js"></script>
<script src="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/hover.js"></script>
<script src="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/my_be.js"></script>
<script><?= $this->getDateString() ?></script>
<?= $this->javascripts ?>
</head>
Weiters muss man über den Contao Manager unter Systemwartung (am besten alle) Schritte noch ausführen, damit die neuen
DCA Files dann auch funktionieren.
Ich denke das könnte man sicher noch besser lösen (eventuell auch mit einer kleinen eigenen Erweiterung) damit es updatesicher
bleibt, nur da hab ich noch zu wenig Wissen dafür.
Wenn also jemand sich dem annehmen würde/möchte (ich weiss ja nicht was das an Zeit benötigt um das in einer eigenen kleinen
Erweiterung umzusetzen) würden sich sicher noch ein paar Contao Nutzer freuen.
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
wie wäre along dazu die Anzeige für die Neuigkeiten?
Die Liste der Beiträge in einem Newsarchiv?
Anhang 21294
folgende klappen nicht
$GLOBALS['TL_DCA']['tl_news']['list']['label']['fields'][] = 'alias';
$GLOBALS['TL_DCA']['tl_article']['list']['label']['fields'][] = 'alias';
$GLOBALS['TL_DCA']['tl_content']['list']['label']['fields'][] = 'alias';
Danke für die Hilfestellung